Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

When I use fprintf:

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

It prints '\r\n' to the file. How do I just print '\n'?
I'm writing to a binary file. The code above is just for debugging.

like image 857
Property404 Avatar asked Aug 21 '15 15:08

Property404


1 Answers

When you open the file you have to open it in binary mode and not in text mode. This is done like this:

fopen("filename", "wb");
like image 191
trenki Avatar answered Oct 02 '22 13:10

trenki