+ 3
Does endl and '/n' serve the same purpose?
17 odpowiedzi
+ 8
It's almost the same.. but \n don't automatically flush the stream while endl does... This difference is not always significant in small and simple codes like the ones used in this tutorial but it's something you have to take into account.
+ 5
(cout << endl;) and (cout << ”\n" << flush;) serve the same purpose.
+ 2
it's "\n" by the way. Thanks
+ 2
but endl jumps the cursor and flush te buffer so it's not the same thing
+ 2
i think think it's no matter but i prefer \n one cz It's a little bit easy.
+ 1
yes but i think after cin >> u cant add /n u need to type cin << x << endl;
0
"endl" and "\n" works d same. its Not "/n".
0
You should prefer "\n" over endl
0
yes
0
yes, they are the same if we write endl it's a little bite easier than "\n" bcz it's need double quotation mark.
0
yes
- 1
yes. both moves the cursor to next line.
- 2
yes it does
- 3
Yes, it does. They both start a new paragraph. For example: cout <<"Hello\nWorld!"; would be the same as cout <<"Hello" <<endl <<World!;
- 3
<<endl provides more neat code than \n
- 3
(cout << endl;) and (cout << ”\n" << flush;) serve the same purpose.
- 5
Yes, but the 'std::endl' is platform-independent. That is, you can use it on windows too, whereas the '\n' would fail, cause '\0' is used on windows.