+ 1

Is using \n in c++ for new line a good practice?

or should we go with endl? isn't \n specifically for C?

26th Dec 2016, 1:49 PM
Arch.ary
Arch.ary - avatar
5 Antworten
+ 3
I believe "\n" is more practical in complex command line programming where you compose dynamically the output. endl looks better in the code when you use a simple output.
26th Dec 2016, 2:19 PM
Michael Isac Girardi
Michael Isac Girardi - avatar
+ 1
yeah! This is a good pratice in this and more programmer langues
26th Dec 2016, 2:34 PM
Yanka Santos
Yanka Santos - avatar
0
`std::endl` calls `flush` stream while `cout << "\n"` does not, so "\n" should have better performance.
26th Dec 2016, 1:54 PM
Ondřej Doněk
Ondřej Doněk - avatar
0
Not compulsory....But its a good practice just for good visual view and easy understanding!
29th Dec 2016, 8:30 AM
Mohit Kulkarni
Mohit Kulkarni - avatar
0
If you understand the the similarities of \n and end , yes it is good pratice.
1st Jan 2017, 3:30 PM
Tails Ex Machina
Tails Ex Machina - avatar