Differentiate between \n and endl | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Differentiate between \n and endl

Avoid using any non trivial word like buffer

1st Feb 2019, 8:13 PM
preetish patel
preetish patel - avatar
1 Answer
+ 5
But what's wrong with buffer? 😁 Okay then, I will try ... when you use "\n" you tell the program to move the cursor one row down, this way whatever you will write after that "\n", will be written on the next line. But if you use `endl;` you tell the program to do what "\n" do, plus make sure whatever was written before the `endl;` are immediately drawn on screen, with "\n" alone, that didn't happen, not until the program thinks its time to do it. P.S. Add C++ to Relevant Tags ... Hth, cmiiw
1st Feb 2019, 8:44 PM
Ipang