I need to write a little program in C, which recives only numbers.
As a part of this program I need to create a validation that user input will be only numbers,
otherwise the program should display an error.
I have read about the isdigit() function, but it’s not working for me. Do you have other solutions for me?
hours and minutes are user input, and defined as integers.
if (!isdigit(hours) || !isdigit(minutes))
{
printf("Invalid Time\n");
}
You will need to check every character of the input to determine if they are digits or not: