Should i use strtol() in my program to turn the input from fgets to integers on the questions where the user is asked to input age?
is this correct usage of what Salem coded:
Code:#include<stdio.h> int main(void) { char buff[4]; int iTestInput; do { printf("Please enter your age: "); iTestInput = fgets(buff, sizeof buff, stdin); }while (iTestInput == 0 && fgets(buff, sizeof buff, stdin) != NULL) ; if (buff < 18) { printf("young"); } else if (buff >= 18) { printf("not young"); } return 0; }