+ 1

What does endl mean in this?

int x ;x = 4 + 6; cout << x endl;

12th Jan 2018, 7:53 PM
Walker Haywood
Walker Haywood - avatar
5 Réponses
+ 4
First, it should be ...x << endl. endl adds a system dependent END of Line to your output.
12th Jan 2018, 8:09 PM
John Wells
John Wells - avatar
+ 2
Like pressing ENTER in a text document.
12th Jan 2018, 9:20 PM
Jacob Pembleton
Jacob Pembleton - avatar
+ 2
It does not end a function, does the exact same job as \n
12th Jan 2018, 9:34 PM
Jacob Pembleton
Jacob Pembleton - avatar
+ 1
@John Wells, so ending the line of my output, does that mark the end of my function as well? Because I thought that endl was simply an archaic version of \n, which indents the text for me like this.
12th Jan 2018, 9:20 PM
Walker Haywood
Walker Haywood - avatar
+ 1
The \n is the archaic version. There exist systems where \r is the end of line character. endl will use the correct character on both types of system.
12th Jan 2018, 9:52 PM
John Wells
John Wells - avatar