The number part executes nicely but whenever I put strings into the input....the while starts an infinite loop.Code://#include blah blah blah... using namespace std; class token { public: bool status;//0 for str & 1 for num string str; double num; } ; typedef vector<token> storage; int main() { string a; token t; storage s; double x; string y; getline(cin,a); istringstream st; st.str(a); while(!st.eof()) { if(st>>x,x) { t.status=true; t.num=x; cout<<t.num<<'\n'; } else { st>>y; t.status=false; t.str=y; cout<<t.str<<'\n'; } //cout<<t.status; s.push_back(t); } }
btw_ this is for parsing the input for a calculator program...
Any idea what is going wrong...or a better way to put the different parts of the input line to be analysed separately later?