if (cin.fail())
{
cout << "Bad input, please enter another positive integer (use cnt-Z to quit)" << endl;
cin >> number;
return 0;
}
To start, this is an if, not a function. That return terminates your program. You'll have to get rid of it.
Once you've corrected that, look up the istream::ignore() function , the ios::clear() function , and read this thread . You'll also have to modify the structure of your loops.
Fbody
Posting Maven
2,930 posts since Oct 2009
Reputation Points: 833
Solved Threads: 393