I need my program to output a message "invalid input" when the input is not correct by the user.
Currently my programs use is to allow the user to enter a number and the program outputs that number in words.
This is whats meant to happen:
Input: 30
Output: thirty
Input: 30 eight
Output: invalid input
This is what happens:
Input: 30
Output: thirty
Input 30 eight
Output: thirty
Can anyone help me with how to get the invalid input thing to work. Here is a snippet of my code:
Code:int res; int num; res = sscanf( cmd, "%d", &num); switch(num){ /*0 - 20*/ case 0: printf("zero\n"); break; case 1: printf("one\n"); break; case 2: printf("two\n"); break; case 3: printf("three\n"); break; case 4: printf("four\n"); break;