Challenge (*SPOILER*)


#1

This is my answer to the challenge which relates as closely to the book as possible so that you can understand it better as it helped me to. Check it out down below.

[code]#include <stdio.h>
#include <time.h>

int main(int argc, const char * argv[])
{
/*
long secondsSince1970 = time(NULL);
printf(“It has been %ld seconds since 1970\n”, secondsSince1970);

struct tm now;
localtime_r(&secondsSince1970,&now);
printf("The time is %d:%d:%d\n", now.tm_hour, now.tm_min, now.tm_sec);
*/

int seconds = 40000000;
long secondsSince1970 = time(NULL);
secondsSince1970 += seconds;
struct tm now;
localtime_r(&secondsSince1970,&now);
printf("The day will be %d:%d:%d when %d seconds is added\n", now.tm_mday, now.tm_mon+1, now.tm_year +1900, seconds);

 return 0;

}
[/code]