Hey guys i need to find out how many days there are in a particular month in a particular year.

How can i start building an algorithm like that im having some trouble?

Hey guys i need to find out how many days there are in a particular month in a particular year.

How can i start building an algorithm like that im having some trouble?

Since there's no relation between the month and the number of days it contains, your best (portable) option is to use a lookup table.
(Or, you could use some non-standard windows function to look it up, but lets go with the portable method for now :) )

std::map<std::string, int> daysInMonth;
daysInMonth["january"] = 31;
daysInMonth["february"] = 28;
//etc

Then, somewhere else in your code, you might have...

std::string myMonth = "january";
int lengthOfMonth = daysInMonth[myMonth];

edit : Oh, of course, this doesn't take leap years into account..

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.