I'm thinking to do it as a character array and then do a loop to go through it,
Rather than a char array, use a std::string which is like a char array but much better. Read it in with std::getline. You can still loop thorough it. Can also use std::stringstream because you know the format.
int day ;
int month ;
int year ;
char s1, s2 ;
std::cout << "enter date as month-day-year (eg. 1-1-2006): " ;
std::cin >> month >> s1 >> day >> s2 >> year ;
// validate: day, month and year hold valid values; s1 and s2 are the character '-'
Are you allowed to use std::string? It's easier if you can, even easier if allowed to use std::stringstream. These containers have built-in functions like substr.
Some pseudo-code:
//Find position of all the "-"
// make sub strings using those positions
// convert sub strings to numbers, possibly with atoi function
Using std::stringstream :
// read in unsigned int, "-" , unsigned int, "-", unsigned int, into month, day, year variables.
> So this question does not have to necessarily be done with functions?
Consider writing functions to
a. validate that the tuple day, month, year represent a valid calendar date.
b. convert the validated tuple day, month, year to number of days elapsed since 1-1-2006.
To just read in three integers separated by '-', doing anything more than
1 2
std::cin >> month >> s1 >> day >> s2 >> year ;
// validate: day, month and year hold valid values; s1 and s2 are the character '-'