如何阻止 fprintf 将 \r 与 Windows 中的 \n 一起打印到文件

How do I stop fprintf from printing \r's to file along with \n in Windows

当我使用 fprintf 时:

fprintf(somefile,"%c",'\n');

它将“\r\n”打印到文件中。我如何打印'\n'?
我正在写一个二进制文件。以上代码仅供调试。

当您打开文件时,您必须以二进制模式而不是文本模式打开它。 这是这样做的:

fopen("filename", "wb");