How to use is_integer in include<limit>?

For example, I have "int x" and I want to check whether if the user has enter a integer, how to I use it like in a "if" loop or maybe other mean.
thanks, but there is still one problem.
for example, I want the user to enter a medical fees and I use a program like this
"
while (true) {
cout << "Please enter a valid number: ";
getline(cin, input);

// This code converts from string to number safely.
stringstream myStream(input);
if (myStream >> myNumber)
break;
cout << "Invalid number, please try again" << endl;
}
cout << "You entered: " << myNumber << endl << endl;
"
if I enter something like "1234zzz"
the stringstream will take "1234" only.
so how can i solve this?
If you want to discard that kind of input, check whether myStream is empty after myStream >> myNumber
erm, how to check? sorry i am just starting to learn sstream.
You can check for myStream.eof()
What is myStream.eof for ?
To check whether the end of the stream was reached
Topic archived. No new replies allowed.