I\'m trying to write a simple code to check if a string only has numbers in it. So far it\'s not working, any help would be appreciated.
#include
#include
#include
int main()
{
char numbers[10];
int i, correctNum = 0;
scanf("%s", numbers);
for(i = 0 ; i < 10 ; i++)
{
if(numbers[i]<48||numbers[i]>57)
{
correctNum = 1;
break;
}
}
if(correctNum == 1)
{
printf("That number has a char in it. FIX IT.\n");
}
else
{
printf("All numbers. Good.\n");
}
return 0;
}