> A program to validate a social insurance number using c programming?

A program to validate a social insurance number using c programming?

Posted at: 2014-12-18 
you could consider input of user a c string and read it in using fgets

you then could use the functions/macros isdigit to validate a position in the user's entry as number.

char buffer[100]

printf("Enter Social Insurance Number: ");

fgets(buffer, sizeof(buffer), stdin);

int iLen = strlen(buffer);

if (iLen != 9) {

puts("9 numbers, only, no delimiters allowed");

exit(0);

}

for (int i = 0; i < 9; i++) {

if (!isdigit(!buffer[i])) {

puts("numbers, only!");

exit(0);

}

}

printf("Congratulation! You entered a correct SIN!\n");

help us by giving the rules.