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.


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

cout << "Day:";
cout << "Month:";
cout << "Year:";

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

Recommended Answers

All 2 Replies

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.

Thanks... I've understood...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.