I have a problem in this code when I enter a string, instead of integer. How do I check if the user has entred a character instead of integer? (I would like to put out a message to the user saying you should use numbers, not characters)
ALSO: if you find anything in this code I can improve, please help me! (I am new to C)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main () {
int secret, answer;
srand((unsigned)time(NULL));
secret = rand() % 10 + 1;
do {
printf ("Guess a number between 1 and 10");
scanf ("%d",&answer);
if (secret<answer) puts ("Guess a higher value");
else if (secret>answer) puts ("Guess a lower value");
} while (secret!=answer);
puts ("Congratz!");
return 0;
}