468,513 Members | 1,862 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

truncate/decrease file

Neo
I want to remove 10 bytes from end of the file, how I can perform this
task using C++ filing functions?
I am not want to make new, write contents, remove input file and rename
output file.
In C++ ios::trunc flag available use for truncation but how to use
trunk flag in my task?

Regard,
-aims

Jul 26 '06 #1
2 8489
Neo

in other words change the size of file using C++ functions...

Regard,
-aims

Jul 26 '06 #2
Neo wrote:
I want to remove 10 bytes from end of the file, how I can perform this
task using C++ filing functions?
I am not want to make new, write contents, remove input file and rename
output file.
In C++ ios::trunc flag available use for truncation but how to use
trunk flag in my task?
ios::trunc, along with ios::out, is the default open mode for a file
opened by an ofstream object. That means when you open a file for
writing, it is truncated to zero, i.e., cleared. So if you want to
truncate 10 bytes off a file...

1. open the file for reading
2. read the contents into a buffer
3. close the file
4. open it for writing
5. write out the buffer except the last 10 bytes.

Kristo

Jul 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Yannick Turgeon | last post: by
1 post views Thread by New MSSQL DBA | last post: by
4 posts views Thread by Amit Kulkarni | last post: by
1 post views Thread by venkat | last post: by
5 posts views Thread by ronin 47th | last post: by
2 posts views Thread by Sharkie | last post: by
5 posts views Thread by Neo | last post: by
1 post views Thread by hedgracer | last post: by
2 posts views Thread by s0suk3 | last post: by
5 posts views Thread by Timothy Madden | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.