LF 字符,不输出 CR 人物。
LF
CR
fprintf(fpout, "some text\n"); 性格 \n 自动替换为 \r\n 在文件中。
fprintf(fpout, "some text\n");
\n
\r\n
有没有一种方法可以专门输出 \n LF )性格?
语言是C++,但I/O函数来自C。
您可以以二进制模式打开文件,例如。
FILE *fpout = fopen("unixfile.txt", "wb"); fprintf(fpout, "some text\n"); // no \r inserted before \n
因此,传递到的每个字节 fprintf 被解释为一个字节而不是其他任何内容,这应该忽略从 \n 到 \r\n .
fprintf
std::fopen :