Hi guys!

I want the user to enter the day, month and year in a dd/mm/yyyy format.
But what i've written doesn't seem to work.

Code:

char d[2];
char m[2];
char y[4];

cout << "Day:";
gets(d);
cout << "Month:";
gets(m);
cout << "Year:";
gets(y);

In the output, it doesn't stop for Day, Goes for month.. and suddenly program crashes at Year. Any Help?

why are you using character arrays instead of integers?

why are you using C's gets() function instead of c++ cin?

If you really really want to use character arrays then you need to make them larger -- you have to account for the string's NULL terminating character. With integers you don't have to worry about that.