Three integers for the current date, three integers for the DOB, then find the difference given an array of the lengths of months and the algorithm for checking if a year is a leap year (year divides by 4 and not 400).
Call time() to get the current data/time. This will give you the current time in seconds snce 1970. There is no function in time.h that returns the number of seconds since year 0 because it would be too big a number.
Now, once you have the year, month and day of birth, populate a struct tm with it and call mktime() to covert to seconds sine 1970.
struct tm tm;
int month = 1;
int year = 2010;
int day = 1;
time_t today, dob;
tm.tm_year = year - 1900; // Number of years since 1900
tm.tm_mon = month-1; // months are 0 based, so that 0 = Jan, 1 = Feb, etc
tm.tm_mday = day;
dob = mktime(&tm);
today = time(0);
double diff = difftime(today,dob);
printf("dob = %u\n", dob);
printf("diff = %lf\n", diff);
The code I posted earlier will get you the difference in seconds. All you have to do is make the calculations that I posted here.
I'm not going to do all the homewoprk for you. You have to learn how to use your head for something other than a hat rack. This problem is nothing more than 4th grade math. How many years are there in X number of seconds. Any 10 year old should be able to solve that problem.
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
OK, so HostGator for some reason no longer allows gcc/g++ access unless you have a Designated Server account, which is a lot of money to spend just to compile my "Hello World" program. Thus I figured I'd compile at home, then upload. Program is your regular old bare-bones Hello World ...