hi, guys
when I run the following code in Xcode3.2.1 on Mac Snow Leopard 10.6.5,
the code dose't work as I suppose.
if I enter: 10+10 return
no results at all
so I enter a random integer and return again
no results still
so I enter another random integer and return again
it displays: result:20
however the program doesn't end, it seems like waiting for input.
I tried ctrl+D or ctrl+U, they don't work either.

when I run the following code in Xcode3.2.1 on Mac Snow Leopard 10.6.5,
the code dose't work as I suppose.
Code:
#include<iostream>
using namespace std;
int main()
{
cout<<"enter expression:";
int lval,rval;
char op;
cin>>lval;
if (!cin) cout<<"no first operand";
while (cin>>op) {
cin>>rval;
if (!cin) cout<<"no second operand";
switch (op) {
case '+':
lval+=rval;
break;
case '-':
lval-=rval;
break;
case '*':
lval*=rval;
break;
case '/':
lval/=rval;
break;
default:
cout<<"result:"<<lval<<"\n";
break;
}
}
cout <<"bad expression";
return 0;
}
if I enter: 10+10 return
no results at all
so I enter a random integer and return again
no results still
so I enter another random integer and return again
it displays: result:20
however the program doesn't end, it seems like waiting for input.
I tried ctrl+D or ctrl+U, they don't work either.