I would like to take in an input from the user that's supposed to be a number. I want to validate the input, and if it's not a number prompt the user to try again. If it is a number, I want to continue.
I'm thinking I will need to take the input as a string, and check to make sure it is only one numerical digit. If it is, I can convert it to an integer. My question is this: How do I check to see if it's longer than one character, and whether or not it is a number. For example, if the output is "enter any number: " and the user types in "what?" I would like to prompt them to try again.
I've done a Google search for "string parsing C" and the results showed me how to use a delimiter to break a string up, and maybe there is a way to use strtok to break off just the first character and discard the rest, but I didn't see anything showing me that.
Any help is greatly appreciated. Thanks!