using cout inside a while loop

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int first, second;
    while (cin >> first >> second);
    {
     cout << first << " " << second << endl;
    }
 return 0;
}


I have the above program. I wanted to test the cout output within a while loop. My problem is this program does not print anything on the screen until I leave the while loop by hitting a not numeric key. How can I print both numbers inmediately after I typed in?, and keep tyiping and the program should keep printing it.

Thanks in advance.
closed account (zb0S216C)
You need to remove the semi-colon after the condition of the while loop.

Wazzak
Framework (994) Aug 8, 2011 at 7:29pm
You need to remove the semi-colon after the condition of the while loop.


I knew I had to post my problem in the begginers forum.

Thanks!.
Topic archived. No new replies allowed.