Output methods

I know of (at least) two methods for writing information to files, one being the

...>>"Stuff to write" >>endl;

method and the other which uses the cstdio library, for example

fprintf(outfile, "Stuff to write");

Since both can give output, why are there two methods, and most importantly, which is the fastest and better for binary output?
Neither of them are particularly efficient, they both are flexible in their own ways. Output streams "<<" not can extract data from defined stream function for that particular data type/class. "fprintf(...)" Allows the flexibility to use many different data types and format them.

1
2
3
ofstream outfile ("new.txt", ofstream::binary);
outfile.write(data, size);
outfile.close();


Is fast, you just have to handle any conversions and the formatting yourself.
Topic archived. No new replies allowed.