How to tell if user input is a float, int, or letters in C

Опубликовано: 02 Ноябрь 2024
на канале: Painless Programming
11,863
100

A more detailed analysis of how to read in user input in C and check to see if the user entered a valid floating point number, int, or something else.

To do this, I read the user input into an array of characters.
Then loop through every character individually to check to see if they are in the range 0-9, a period, or something else.

After I have determined the data type, I'm able to convert to an int or float data type if applicable.