0

why cant we use \n for new line instead of endl

cout<<"hello world\n"; cout<<"i love programming"; //prints same without endl

21st Feb 2017, 4:14 PM
Kakara Chandra Sekhar
Kakara Chandra Sekhar - avatar
4 ответов
+ 1
because many people came c programming background and we use every time \n so we used \n
21st Feb 2017, 4:17 PM
meherDev
meherDev - avatar
0
You can. If that is what you prefer, feel free to do so. However, it's not the typical standard convention and when working with a group or team may be frowned upon in some cases. I usually use \n if i need a newline somewhere before the end of that statement, but use endl if it is the last argument. For me this tends to be easier to read when looking over old code. Also, using \n requires less typing, so that's a plus in my book. ;-)
21st Feb 2017, 6:57 PM
ChaoticDawg
ChaoticDawg - avatar
0
"\n"can be used anytime you like, i feel its an alternative but basically "endl" is a standard ok?
24th Feb 2017, 12:58 AM
Ofeoritse Temiatse
0
Ofeoritse c haven't any 'endl' code, so!!
24th Feb 2017, 4:44 AM
meherDev
meherDev - avatar