how do I check if a c++ string is an int?
- by user342231
when I use getline, I would input a bunch of strings or numbers, but I only want the while loop to output the "word" if it is not a number.
so is there any way to check if "word" is a number or not, I know I could use atoi() for
c-strings but how about for strings of the string class
int main () {
stringstream ss (stringstream::in | stringstream::out);
string word;
string str;
getline(cin,str);
ss<<str;
while(ss>>word)
{
//if( )
cout<<word<<endl;
}
}