G
Gregc.
G'day
I'm trying to work out the number of years since 1970, here is my code:
include <stdio.h>
#include <time.h>
const int SEC_IN_MIN = 60;
const int SEC_IN_HOUR = SEC_IN_MIN * 60;
const int SEC_IN_DAY = SEC_IN_HOUR * 24;
const int SEC_IN_YEAR = SEC_IN_DAY * 365;
int secToYear(int seconds) //Function Protoype
{
seconds = (SEC_IN_YEAR);
return (seconds);
}
main () {
time_t now = time(0);
printf("%i seconds since 1/1/1970\n",secToYear(now));
}
For some reason the answer is coming out as 1. Could someone offer me
some guidance.
Thankyou
Greg
I'm trying to work out the number of years since 1970, here is my code:
include <stdio.h>
#include <time.h>
const int SEC_IN_MIN = 60;
const int SEC_IN_HOUR = SEC_IN_MIN * 60;
const int SEC_IN_DAY = SEC_IN_HOUR * 24;
const int SEC_IN_YEAR = SEC_IN_DAY * 365;
int secToYear(int seconds) //Function Protoype
{
seconds = (SEC_IN_YEAR);
return (seconds);
}
main () {
time_t now = time(0);
printf("%i seconds since 1/1/1970\n",secToYear(now));
}
For some reason the answer is coming out as 1. Could someone offer me
some guidance.
Thankyou
Greg