get and check input as while condition
How can I get and check the user input from within the condition of a while loop?
For example, the Java equivalent would be
Code:
BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
while (Integer.parseInt(new StringTokenizer(br.readLine()).nextToken()) != 999)
do something as long as input isn't 999
the first line isn't important, but anyways, I just want to know how to test the input in the while loop condition.
I tried
Code:
int a;
while ((cin >> a) != 999)
but that only tests the input stream, not the actual value of a.
Is there another operation other than cin >> that I can use?
Thanks.