+ 1
Is the newline character only for outputting strings or is it just my syntax?
Total beginner, just going through the basic concepts. cout <<"Hello World\n;" // this gives a new line just fine int x=6; cout <<x\n; // this doesn't work, nor any variations of it I've tried int x=6 cout <<x<< endl; // this, of course, works just fine
3 odpowiedzi
+ 3
'\n' is a char so you have to insert that into cout after x, so
cout << x << '\n';
+ 1
or std::endl
0
What about a blank line?
int x = 6;
cout << x << '\n\n' ;
cout <<"New line";
// outputs '62570New line' for some reason