Hi,
It's my understanding that if you don't use endl to clear the buffer or something like that....a lot of stuff can remain there and be printed out in subsequent output statements?
'\n' puts a newline at the end of the output, so you can do this:
cout<<"some text\n";
endl tacks on a '\n' to the output and calls flush() if the stream is buffered(is cout buffered?) It doesn't seem like cout is buffered:
Code:
#include <iostream>
using namespace std;
int main()
{
cout<<"bye";
return 0;
}
displays the text with my compiler. Maybe the compiler flushes the stream before ending the program.
cin.ignore() is the same thing as cin.ignore(1) because 1 is the default value. It ignores one character in the input stream. ignore() actually has two parameters and the second one is the delimiter--ignore will skip the number of characters specified or until it hits the delimiter.