Hi, just got round to introducing some functions into my C program but am having a problem.
im trying to introduce two variables into a function which will use the time functions in C to convert the two variables into a time and calendar date.
different sections of the time and date (i.e. the numer of the day, hour) are then stored into seperate strings and sent back towhere they are then used for further uses.Quote:
int main
when i compile, i get the error :im using this code in my header file which is called by the line in the main program:Quote:
old style header.....
header file:Code:int GPS_calculate(int GPSweek, int GPSsec);
all help would appreciatedCode:int GPS_calculate(int GPSweek, int GPSsec);
{
double abs_GPS;
time_t current;
struct tm* loctime;
abs_GPS = ((604800 * GPSweek) + (GPSsec)); /* convert to absolute GPS time */
current = (abs_GPS + 315964800); /* Add absolute GPS time to the UTC epoch */
loctime = localtime(¤t); /* Convert it to local time representation */
fputs(asctime(loctime), stdout);
fputs("\n", stdout); /* Print out the date and time in the standard format */
strftime(bufftime, SIZE, "%y %m %d %H %M %S", loctime); /* Print out the date and time in needed format. */
sscanf(bufftime, "%8d", &time);
/*THE DAY*/
strftime(buffday, SIZE, "%j", loctime); sscanf(buffday, "%3d", &day); // printf("Day is: %3d ", day);
/*THE YEAR*/
strftime(buffyear, SIZE, "%Y", loctime); sscanf(buffyear, "%4d", &year); // printf("Year is: %4d ", year);
/*THE HOUR*/
strftime(buffhour1, SIZE, "%H", loctime); sscanf(buffhour1, "%2d", &hour); // printf("Hour is: %2d ", hour);
strftime(buffminute, SIZE, "%M", loctime); sscanf(buffminute, "%2d", &minute);
return (buffyear[12], buffday[12], buffhour[30], buffhour1[12], buffminute[10], bufftime[19]);
}