[code]#include <stdio.h>
/* Also, include the <time.h> header at the start of your program.*/
#include <time.h>
int main(int argc, const char * argv[])
{
/**********************Challenge***********************/
/*Your challenge is to write a program that will tell you what the date (4-30-2015 format is fine) will be in 4 million seconds*/
/*Calculate and print the number of seconds that have passed from 1970 in Greenwich England to now.*/
long secondsSince1970 = time(NULL);
printf("The time now from 1970 in Greenwich England is %ld seconds.\n", secondsSince1970);
/*Calculate and print the number of seconds four million seconds from now.*/
long fourMillionSecondsFromNow = secondsSince1970 + 4E6;
printf("Four million seconds from now is %ld seconds.\n", fourMillionSecondsFromNow);
/Use the struct tm, which is the standard C library uses to hold time broken down into its components. Reference: http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf page 406 0f 701./
struct tm laterDate;
localtime_r(&fourMillionSecondsFromNow, &laterDate);
/*Hints: tm_mon = 0 means January, so be sure to add 1 and tm_year = 1900, so be sure to add 1900 to your year.*/
printf("The date is %d-%d-%d\n", laterDate.tm_mon+1, laterDate.tm_mday, laterDate.tm_year+1900);
return 0;
}
[/code]