I'm trying to get user input and allowing them to only input a whole number which is also positive.
I'm trying to figure out this task
printf("Enter the first and second number in whole number: ");
scanf("%d,%d", &first, &second);
if (input != '\n') //notice this line I'm trying to check if is a character//
printf("Error! CHARACTER NOT ACCEPTED!!\n");
else if (First <= 0)
printf("Error! First must be a positive value!\n");
else if (Second <= 0)
printf("Error Second must be a positive value!\n");
The code above will check for two things. One, if the user has input the characters I want. Second, if the number is positive.
How do I realize these checks?