#include <stdio.h>
#include <string.h>
#include <ctype.h>
int isdigits(char *s){
//return value : true if the string is all numbers.
while(*s)
if(!isdigit(*s++))
return 0;
return 1;
}
int main(void){
char dateOfBirth[7];
int len;
set4:
printf("Date of Birth (DDMMYY) : ");
//Doesn't accept input more than specified number of characters
fgets(dateOfBirth, sizeof(dateOfBirth), stdin);
rewind(stdin);//keyborad buffer flush
//fflush(stdin);//discard the character exceeding the amount of input
//How fflush will work for stdin by the processing system (that is undefined)
//while ('\n' != fgetc(stdin));//skip if over inputted
len = strlen(dateOfBirth);
if(dateOfBirth[len-1] == '\n') dateOfBirth[--len] = '\0';//newline drop
if(len != 6 || !isdigits(dateOfBirth)){
printf("\nSorry, input is invalid\n");
goto set4;
}
return 0;
}