x25
asked on
Flush IO Stream
i have function as follows:
void func()
{
char a;
.........
cout << "Enter: ";
cin >> a;
.........
}
However, on the next iteration of cin >> a, a would have the value of '\n'
which was entered in the first place. Someone told me to flush the io stream on each iteration. How ?
void func()
{
char a;
.........
cout << "Enter: ";
cin >> a;
.........
}
However, on the next iteration of cin >> a, a would have the value of '\n'
which was entered in the first place. Someone told me to flush the io stream on each iteration. How ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
bdflush is a Linux thing, not a C thing. If your program is to run under Linux, you can use bdflush in C++ as well as in C. But since it has to do with flushing buffers to disk, I don't think it would help you with a cin input stream.
ASKER
cin.ignore() works fine.
Thanks, it is now accepting the input using cin.ignore. BUT my Customer Search runs into a problem now.
When I enter a customer number, it will find it, display the Customer No. but then the ERROR below pops up:
An Access Violation (Segmentation Fault) Raised in your program
When I enter a customer number, it will find it, display the Customer No. but then the ERROR below pops up:
An Access Violation (Segmentation Fault) Raised in your program
Sorry, wrong question!! :-)
ASKER