• Advertisement

Archived

This topic is now archived and is closed to further replies.

Binary File Manipulation

This topic is 5492 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have searched around a lot but I have not found much about using ifstream for binary files. I can do some basics but not much better. Does anyone know some good web sites or books about it? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
For binary files, I have to recomment you use the stdio FILE* functions, like this:

FILE *f = fopen("out.bin", "w");
for(int t = 0; t < 100; t++)
{
fwrite(f, (void*)&t, sizeof(int));
}
fclose(f);

This writes the binary numbers 0 to 99 to a file (I think my fwrite statement is right... I just whipped it out).

This is my preferred way of doing it, it''s very little code for good effect.



~BenDilts( void );

Share this post


Link to post
Share on other sites

  • Advertisement