Is first character in a string numeric?

In looking online I see that the isdigit function under <cctype> can test whether or not a character is a digit.

Can this function check if the first character in a string is a function?

If so how? thanks

isdigit will check if a character is between '0' and '9'. How can a character be a function?
I think it might be.
you could initialize a function pointer with that first character from the string, within a try/catch block, and if returns an error, not a function, if it does not return error, than it's a function. but you need to know more about the candidate functions, otherwise you can't create the pointer.
I don't know how you can do this, just theory. but isdigit definitely can't do it. as far as I know...
Last edited on
Yes. Pass to the isdigit() function the first character of the string. If your string is std::string or an array of chars, you can access the first digit via <variable name>[0].
Topic archived. No new replies allowed.