c++ - Unwanted Carriage Returns in ofstream -
this question has answer here:
the following c++ code:
ofstream out("file.txt"); const char *str = "0\r\n1\r\n2\r\n"; out << str; creates following file (file.txt above):

why there cr's , lf's? platform windows 7 , compiler vs 2013.
the situation above cause problem of program parse file line line , program assumes every line contain data. remove empty lines want understand why when str saved, there cr's , lf's.
\n outputs platform-specific newline, in case each \n written \r\n. not need manually add own \r, source of duplication.
Comments
Post a Comment