What is the difference between endl and \n ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between endl and \n ?

20th Jan 2017, 6:37 PM
Ravikumar Ronad
Ravikumar Ronad - avatar
4 Answers
+ 2
they both are same but with a minor difference cout<<endl ; will do same as cout<<"\n"<<flush; flush is used to clear the buffer.
20th Jan 2017, 7:02 PM
Rishabh Agrawal
Rishabh Agrawal - avatar
+ 1
they do the same thing. \n must be within the quotation marks cout << "Hi\n"; using endl will be separate cout << "Hi" << endl;
20th Jan 2017, 6:42 PM
Jonathan Baumert
Jonathan Baumert - avatar
0
Thank you But Better to we can use newline, Because it's reliable for programming..!
20th Jan 2017, 6:45 PM
Ravikumar Ronad
Ravikumar Ronad - avatar
0
Thank you !
20th Jan 2017, 7:04 PM
Ravikumar Ronad
Ravikumar Ronad - avatar