yup.. i have a little bit experience in C++..but i'm still learning and i find it difficult... my programming teacher always tells us to do different kinds of programs, but she didn't even try to discuss it to our class and explain how we are going to start..
I have been messing about with time_t and it's associated functions over the past couple of weeks.
That might be a good place to start looking.
Search out time_t on this website
//need to include this header
#include <time.h>
char *weekDays[] = { "Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
tm timeStruct;
int yearReqd = 2008; //the year you want to check
//zero the structure. We will set some params later
memset(&timeStruct, 0, sizeof(timeStruct));
timeStruct.tm_year = yearReqd - 1900; // the value required in this member is the offset from year 1900
timeStruct.tm_mon = 0; //0 (january) -> 11 (December)
timeStruct.tm_mday = 1; // day of the month
//call the mktime function. This will return a value indicating the number of seconds since 00:00 hrs 1 Jan 1970 or -1 error code
//if it cannot calculate a valid time,
//we are interested in the side effect in that it will fill in the tm_wday member of the structure.
//This will have a value 0 (Sunday) to 6 (Saturday)
if ( mktime(&timeStruct) != -1)
{
cout << "The first day of year " << yearReqd << " is a " << weekDays[timeStruct.tm_wday] << endl;
}
else
{
//error stuff here
}
Boost offer open-source multi-platform standards compliant C++ libraries. Many of the Boost libraries will actually be part of the 2009 C++ Standard. So it's a good choice to use them if you have the choice.
A number of people hare are suggesting the use of this library.
I've recently acquired a book Beyond The C++ Standard Library - An Introduction To Boost, so I'll be getting into that in the v.near future.
Boost is a good addition to your toolset. It's not uncommon for job descriptions to have "Boost" listed as a required skill.
Personally, I am a fan of
foreach - allows you to go
1 2 3 4
// I have #define foreach BOOST_FOREACH so I can use foreach :)
BOOST_FOREACH(string mystring, vstringlist) {
cout << "String From Vector Is: " << mystring << endl;
}
thread - platform independent multi-threading.
program options - Automatic handling of command line parameters.
e.g