I realize that the output is the same.
case 1:
cout << "enter password " <<flush;
case 2:
cout << "enter password " <<endl;
I realize that the output is the same.
case 1:
cout << "enter password " <<flush;
case 2:
cout << "enter password " <<endl;
endl
adds an end of line characters to the output before flushing the buffers. flush
only flushes.
cout is buffered. Text that goes into it might be held in memory until more text comes through, then it all goes out at the same time. This is more efficient but comes at the cost of not displaying all the text in its buffer sometimes.
I expect flush flushes the buffer so that all the text gets output right away.
I don't know whether flush also provides an end of line terminator.