TITLE: Mixing streams and standard IO RESPONSE: clamage@Eng.Sun.COM (Steve Clamage), 2 Sep 94 [...] 1. You can mix stdio and iostreams in the same program using different files with no problems. E.g. FILE * file1 = fopen("data1.dat", "rw"); fstream file2("data2.dat"); 2. You can mix output to stdout and cout in the same program, but on most systems you must first invoke the static member function ios::sync_with_stdio(); Example: main() { ios::sync_with_stdio(); cout << ... printf(...); cout << ... printf(...); ... } You must invoke the sync function before attempting any output. 3. Other forms of mixing iostreams and stdio functions to the same file (other than cout/stdout cerr/stderr) are unlikely to work unless you go to some extra trouble: a. Make the stream unit-buffered, and b. Flush the stdio file before every stream output. Some iostream implementations, notably the one from Gnu, have no special restrictions on mixing iostreams and stdio, since they use the same data structures. The C++ Standard version of iostreams will mandate mixing of output on cout/stdout and cerr/stderr without taking any special action. Most current implementations have the restrictions I have noted. What about input? Well, if two objects (an istream and a FILE) are each buffering input independently, it is pretty hard to synchronize them. It is very unlikely to work.