I created a program that accepts 3 numbers separated by comments which I will use to do some calculations. It will accept user input for these numbers and I'm using scanf to accept that.
Here is what I have so far:
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <stdbool.h>
int main(void)
{
float a, b, c;
bool continue_program = true;
while (continue_program) {
printf("Enter your coordinates: ");
scanf("%f,%f,%f", &a,&b,&c);
if(isdigit(a) && isdigit(b) && isdigit(c)){
printf("Success!");
} else {
printf("Try again!");
}
}
}
Example Output:
Try again!Enter your coordinates: Try again!Enter your coordinates: Try again!Enter your coordinates: Try again!Enter your coordinates: Try again!Enter your coordinates: Try again!Enter your coordinates: Try again!Enter your coordinates: Try again!Enter your coordinates: Try again!Enter your coordinates: Try again!
I know that other people have also faced the same issue and went through the answer for those ones but couldn't get their implementations working for this code.