A question about file I/O...

Started by
4 comments, last by Moe 21 years, 11 months ago
I am wondering what is the most commonly used method for file input/output for windows based text/binary files? I have seen people use ''FILE'', and I have seen people use fstream. Is there much of a difference between the two in terms of performance/ease of use? Moe''s site
Advertisement
I don''t know about perfomance but I''d go with fstream for ease of use.

Firstly, who doesn''t know how to use << and >>? What''s more, you can overload the << and >> operators for your classes.
using the standard c funtions is easy as well. i mean who dont know how to use fread()/fwrite()? whats more you can wrap the functions for your use.
Basiclly i would say use fstream if your going to be extracing data into a C++ String..

string temp;

User fread/fwrite if your going to be extracting data into a C Character string

char temp[30];

C++ streams are easier and safer. Typesafety is one of the greatest things you can have.
Now what about reading in files that are mixed numbers and characters? Does that really change anything?

Moe''s site

This topic is closed to new replies.

Advertisement