2

I have a C app that logs to a file.

I installed the monitor plugin for notepad++ to automatically update, similar to 'tail' on Linux.

My app writes the lines with \n\r at the end ( e.g. fprintf(fp, "%s\n\r","Test"); )

I get something like:

Line 1

Line 2

instead of

Line 1
Line 2

When viewing (no matter the EOL conversion) with 'View->Show Symbol->Show End of Line' I see:

Line 1[CR][LF]
[CR]
Line 2[CR][LF]
[CR]

It is as if it is treating \n as a [CR][LF] and \r as [CR] which is adding another line.

Any ideas?

4

3 回答 3

2

Try using only \n. The windows sees \n as a new line than \r as a carret return which causes it to break another line, if u use \r\n it would cause only one line break.

Also You can check this article for additional reading.

于 2013-05-21T07:12:05.363 回答
2

I think the problem isn't clear from your description, The title suggests that you have problem with the NPP but your explanation shows that you have problem with the App Code.

for NPP: You can remove those extra new Lines from the file.

for App: If you are strictly going with Windows O.S. then use just '\n' or else if you are using other O.S. also then first find out the new line character for that O.S. and apply that.

于 2013-05-21T07:20:14.313 回答
0

The escape sequences may be os-dependent on the , as I heard some months ago.

So, the \n in this case seems to cover both .

I Would experiment with the escape sequences.

But prior to that : Have a look inside fp.... there could also be some sequences.

于 2013-05-21T07:12:23.940 回答