WHOAH. I've never seen this happen with saving files!
This is the wierdest thing and it took me all day to find this problem. However, I have no clue why it''s happening. Here''s some code:
ofstream outfile;
outfile.open(fileName, ios::app | ios::binary);
for(int j = 0; j < 84; j++)
{
outfile.write((char*)(&tempInt), 1000);
}
outfile.close();
Pretty basic code. It creates a file and I''ve checked the size and it''s 84,000 bytes in size. So far, so good. Now if I change the write function to this:
outfile.write((char*)(&tempInt), 10000);
So that each write writes 10 times as much memory, I would expect a file of size 840,000 bytes. But get this. The file ends up being only 2,204 bytes. How in the world is this happening???? Please, ANY help would be appreciated. I am completely stuck and don''t know where to go. Thaks so much to anyone who replies.
--Vic--
From the STL doc on ostream::write
"The caller must ensure that str really contains at least count characters, otherwise the behavior is undefined."
"The caller must ensure that str really contains at least count characters, otherwise the behavior is undefined."
quote:Original post by Fruny
From the STL doc on ostream::write
"The caller must ensure that str really contains at least count characters, otherwise the behavior is undefined."
Whats the website of the STL doc?
Hmm... that''s not from a website, that''s from a book.
I don''t know if there''s a reference online. You can go check SGI''s website (SGI''s implementation of the STL is among the most popular)
http://www.sgi.com/tech/stl/
I don''t know if there''s a reference online. You can go check SGI''s website (SGI''s implementation of the STL is among the most popular)
http://www.sgi.com/tech/stl/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement