Hi,
Why doesn't the stream states fix the loop?
And doesn't the continue keyword restart a loop?
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int i;
int d = 0;
int main()
{
while(cin >> i)
{
if(cin.good() == 1)
{
d = d +i;
cout << "d = " << d << endl;
}
if(cin.fail() == 1)
{
cout << "failed" << endl;
cin.clear();
continue;
}
}
return 0;
}
Jeff