|
-
February 4th, 2009, 01:59 PM
#6
Re: Difference between ostream and ofstream
 Originally Posted by OneEyeMan
Hi,
Ok, but I have 2 more questions:
1. How do I extend the file to be 110 bytes? Do I just write additional 10 '\0' symbols?
Write whatever you want, so long as it's 10 bytes long. Use unformatted output for this of course.
2. If I later write to those 10 bytes, it will not increase the size of the file, right?
The only time the file size will change is if you write past the current end of the file. Otherwise you'll just overwrite whatever is currently at the file pointer's position.
But when I store the header using ofstream, I can seek behind EOF, and that's where the confusion started...
http://www.cplusplus.com/reference/i...eam/seekp.html
Is that what you're using? That documentation doesn't say anything about what happens if you seek past EOF, so it's entirely possible that it will expand the file size and zero-pad the intervening bytes if you do that. I think there is a function which is explicitly documented to do that somewhere, but I can't find it for now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|