I'm writing a program on a Linux platform that is generating text files that will be viewed on, inevitably, a Windows platform.
Right now, passing std::endl
into a ostream
generates the CR character only for newlines. Naturally, these text files look wrong in MS Notepad.
1) Is there a way to change std::endl
such that it uses CR+LF for newline instead of LF?
2) I know I could write my own custom manipulator, like win_endl
, for generating my own newlines, but I use the std::endl
symbol in a lot of places, and like many programmers, have a tendency to do the thing that requires the least work possible. Could I simply overload std::endl
to produce CR+LF, or is this a dumb idea for maintainability?
NB: I checked out this question, but it's asking about going the other way, and the accepted answer seems rather incomplete.