+ 5
What is difference between "\n" and "endl"
13 Réponses
+ 10
"\n" can be a part of the string but "endl" is a separate thing. I can't think of anything else.
+ 4
endl mainly used
+ 2
Nothing that immediately comes to mind. I suppose endl; is easier to spot and read.
+ 2
endl only exists in C++, "\n" works in many languages
+ 2
\n is used while in programming c I know that about it.
it is used to break line and start with new line
+ 2
\n is an escape sequence, endl isn't.
+ 2
Ace, I don't understand this: "flushes the output buffer", what does that mean?
+ 2
Ace I see, but I have another question, when Do I need to use endl and \n? if I want a faster program can I use all the time \n? \n is slightly faster than endl, or is there a specific cases where I need to use \n and endl?
+ 1
The main difference is hardcoding it in with "\n" assumes the line ending, thus good old Notepad for Windows sees it as one long line with an unknown character at the end of each line.
Windows uses "\r\n" while modern Mac OSX as well as Linux / Unix uses "\n" (old Macs used "\r").