RobC
RobC

Reputation: 511

Notepad++ extra newline

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?

Upvotes: 2

Views: 4487

Answers (3)

Mantra
Mantra

Reputation: 346

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.

Upvotes: 2

icbytes
icbytes

Reputation: 1851

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.

Upvotes: 0

cerkiewny
cerkiewny

Reputation: 2851

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.

Upvotes: 2

Related Questions