+ 1

Can we use \n (escape sequences) instead of endl etc.. in c++

c++

27th Jan 2017, 9:14 PM
Pritam Vivek
Pritam Vivek - avatar
2 Antworten
+ 5
Ofc, It's better when you have something in "", and when you use it like cout<<x; it's easier to just type endl. I don't know, I use both, depending on the situation
27th Jan 2017, 10:30 PM
Filip
Filip - avatar
+ 1
Yes, you can. As you may know, C++ derived from C, where there were no endl, and the only way to make a new line was "\n", so C++ now has two ways to make a new line. But remember to write "\r\n" instead of just "\n" when you are writing to a file, not to a console.
27th Jan 2017, 9:19 PM
Антон Обожин
Антон Обожин - avatar