Mail Archives: djgpp/1997/05/21/11:06:35
Hello.
1. put the line: "cin.ignore(1024, '\n');" before any cin.getline().
Also, replace every
"fflush(stdin)" with the above statement.
2. At the line of the problem (with getline), you read a string and then
parse it to find a number
(by atoi). Why don't you use operator >> ?
cin.ignore(1024, '\n');
if ( !(cin >> number) )
{
cerr << "failed to read number" << endl;
HandleError();
}
In this approach you don't need to test isitNumber. it is done for
you by cin
3. Why don't you use ofstream and ifstream for file I/O ?. The mix between
stdio and iostream
looks unnatural.
The syntax of ofstream and ifstram is simple, and identical to
cin/cout.
4. Good Luck
eyal.
- Raw text -