Property404
Property404

Reputation: 318

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.

Upvotes: 5

Views: 767

Answers (1)

trenki
trenki

Reputation: 7363

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");

Upvotes: 6

Related Questions