Input the month, day, year?

I feel like this in an extremely stupid question, but since this website has proven the most expedient method of getting back on track, I guess I'll shoot:

Please enter the month in format dd mm yyyy:

Don't really know where to start. Would I use a string, or an array?
you may use structure for this and make dd, mm and yyyy members of the structure..
1
2
3
4
5
6
struct DATE{
int dd;
int mm;
int yyyy;
};
DATE d;


now you can access the date member using . operator as d.dd, d.mm and d.yyyy
alternatively you can use class instead of structure....
You have a multitude of options. You can get integers to correspond to the date or a series of strings. You may want to stay with integers since you'll probably want to be able to calculate the difference between two dates or other kinds of problems.

If you want it all in one line you could ask for a string, but also just getting the numbers in a chain of std::cin >> will work as std::cin strips white space characters between multiple inputs and stops at the following white space.

So std::cin >> day >> month >> year; will work if they are integers and kinda of work if they are std::strings (although there might be some bugs.)
Thanks, I was not aware of the functionality of input worked that way (allowing the user to enter multiple cin << statements in a row with a space between each variable).

I was trying to parse a string, and it was too difficult at this point.

Jorb well done, thanks.
Topic archived. No new replies allowed.