I'm doing an exercise with 'cout' and flushing the buffer. Upon reading in the forums, I came across this post:
Most streams by default are line buffered which means they flush any time they see a \n, so in most cases there will not be a difference.
1 2 3 4 5
int z;
cout << "Hello world"; // no \n or endl
cin >> z; // you won't see any output yet...
cout << "\n" << endl; // Now you'll see Hello world
cin >> z;
..but the results were not as described above.
What actually happened was this:
1 2 3 4 5 6 7 8
int z;
cout << "Hello world"; // "Hello World" appeared here.
cin >> z; // Input text, pressed enter when done,
// cursor advanced to next line.
cout << "\n" << endl; // No output besides cursor advancing
// to next line.
cin >> z; // Receives input from what's already
// buffered.
Did I misunderstand his post? Clarification would be helpful, thanks.