How can I get a text file into a string but whith the “\n” in C?

Perhaps you could read the file one character at a time.

Test each character that you read to see if it is a newline character (‘\n’).
If it is not a newline character, print the character that was read.
If it is a newline character, print “\n”.

Good Luck!

Leave a Comment