The return value cin >> i is a stream, not a read value. This means that the operand chain
cin >> i >> j;
You can try the following:
while( (cin >> i, i) < 0. ) { cout << "ENTER A POSITIVE NUMBER: "; }
The comma operator should return the value i , but I have not tested it.
EDIT: Do not use this approach, as David Rodriguez noted that this discards the reading result. Use while( (cin >>i) && (i<0.) ) Instead.
source share