Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C - C++ Learning > stream states
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 4226 of 4370
Post > Topic >>

stream states

by "Jeff Baker" <algorthjb@[EMAIL PROTECTED] > Jul 30, 2008 at 06:17 AM

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
 




 6 Posts in Topic:
stream states
"Jeff Baker" &l  2008-07-30 06:17:01 
Re: stream states
"Alf P. Steinbach&qu  2008-07-30 12:53:36 
Re: stream states
"Jeff Baker" &l  2008-07-30 07:21:27 
Re: stream states
"Alf P. Steinbach&qu  2008-07-30 13:31:10 
Re: stream states
Ben Bacarisse <ben.use  2008-07-30 12:32:36 
Re: stream states
Ben Bacarisse <ben.use  2008-07-30 12:34:55 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 16:13:56 CST 2008.