I've tried
#define BUF_SIZE 256
char msg[BUF_SIZE];
printf("input? ");
while (fgets(msg,BUF_SIZE,stdin)!=NULL){
char *next;
int input = strol(msg, &next,10); //use strol
if ((end == msg) || (*end == '\0')){ //check validity here
printf("invalid\n");
printf("try again\n"); //type anther value
else{
printf("valid\n");
}
What's wrong with my code?
Is that the correct way to check integer input?