How to check string for any number?

What code to use to check string if any number are in there, if it is then return error.
Try something like
1
2
3
4
5
6
7
for(auto& i : stringVariable)
{
    if(i >= '0' && i <= '9')
    {
        return whatEverErrorCodeYouAreUsing;
    }
}
You can do it in one line. See variation 2 of string::find_first_of() here:
http://www.cplusplus.com/reference/string/string/find_first_of/
Topic archived. No new replies allowed.