My problem is, I want to convert a string into a long int. For that, i use an istringstream that way:
long x;
string lString;
istringstream istr;
getLine(cin, lString);
istr.str(lString);
if(!(istr>>x)) return false; //Edited after answer below
(the conversion and the cin are actually in two different methods, I just put the related code together).
The following code returns false if I type "1", but not if I type "1.0". I could search for . in the string and add it if ther isn't, but isn't there a method to convert string to long ?