Loop for input

I have a question about input. I'm very new to C++ and I was wondering how to take input from the user until the user use Ctrl-d to stop. It's a very simple question and I have looked everywhere to try to figure it out. I know it has to be some simple loop but I'm not sure what type of loop and what conditions it has to has. Any help is appreciated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
   #include <cmath>
   #include <iostream>
   using namespace std;
   class integers() {
       public:
           int num();
           int sum();
   };

   int main()
   {
       int i;
       while(True);
       cout << "Pease enter integer values:";
       cin >> i;
   }
while(True); this is an empty loop. true should be lowercase.

Remove the semicolon, and put braces around the block of code which belongs to the loop.

1
2
3
4
5
    while (true)
    {
        cout << "Pease enter integer values:";
        cin >> i;
    }


You probably want to loop until you get an error condition on cin:
1
2
3
4
  do 
  { cout << "Pease enter integer values:";
     cin >> i;
   } while (cin.good());


I've been busy all day and I just now got a chance to reply. Thank you so much. Your help made me realize what I was doing wrong.
Topic archived. No new replies allowed.