C
Charles F McDevitt
I'm converting some old programs that use old iostreams.
In one program, the program is using cout to output to the stdout stream.
Part way through, the program wants to put some binary data out, and changes
the iostream to binary like this:
cout << "this is text" << eol;
binary(cout);
cout << "this is binary" << eol;
text(cout);
cout << "back to text mode" << eol;
Of course, with standard iostreams there aren't the binary() or text()
functions.
How can I make this switch? I can't close and re-open the iostream, since
I have no idea what stdout is connected to. And it appears the only way to
change the mode is in open().
Am I missing something? Is this functionality just not available?
Do I need to rewrite the program in C ?
Is there anything that can be done with ibue() and a custom locale?
In one program, the program is using cout to output to the stdout stream.
Part way through, the program wants to put some binary data out, and changes
the iostream to binary like this:
cout << "this is text" << eol;
binary(cout);
cout << "this is binary" << eol;
text(cout);
cout << "back to text mode" << eol;
Of course, with standard iostreams there aren't the binary() or text()
functions.
How can I make this switch? I can't close and re-open the iostream, since
I have no idea what stdout is connected to. And it appears the only way to
change the mode is in open().
Am I missing something? Is this functionality just not available?
Do I need to rewrite the program in C ?
Is there anything that can be done with ibue() and a custom locale?