I'm new to C, currently studying it on CS50 course on edx.org (this task is NOT from CS50 course).
I wrote the program which asks the user for a date of birth, and then calculates a current age depending on system date.
Now I'm getting values from user this way (GetInt()
and GetString()
are functions from cs50.h
header and library).
// Ask user for his name, and date of birth
printf("Enter your name: ");
char* name = GetString();
printf("Enter your day of birth: ");
int birth_day = GetInt();
printf("Enter your month of birth: ");
int birth_month = GetInt();
printf("Enter your year of birth: ");
int birth_year = GetInt();
But I don't want to ask user 3 times to get a date that he can enter as one line - 18.06.1985 for example.
So the question is - how to get input from user in format DD.MM.YYYY, then store it in the array of integers, as [0, 1, 2], so I would be able to access these values separately later on?