|
From: <and...@su...> - 2003-06-09 00:21:00
|
Dear users:
A)In C, I am using the following function for cleaning the input buffer:
clean_buffer();
void clean_buffer()
{
while(getchar()!='\n');
}
B)In C++ I thought who made this function was the "endl"
I´ve tested some codes like:
char string[80];
cin >> string; // here I put "hello there"
cout << string; // it prints "hello"
cin >> string // here it passes directly and loads in string
"there"
cout << string; // it prints "there"
...
cin >> string; // I put "hello there" again
cout << string << endl; // I´ve put "endl" expecting to avoid "there"
cin >> string; // it passes directly again :-(
cout << string; // it prints "there" again
My Question:
1) How to clean stdin using new C++ commands?
Regards
Andre
|