Tuesday 15 January 2013

epoch - Eposh time not converting date/format in c program -



epoch - Eposh time not converting date/format in c program -

i have been working on code read binary file , convert readable texts. pretty much got done part except epoch time. tried playing around coding still can't work. right way have programme coded, first line print yv2827 kclt ksrq 1389396780 (eposh time) wed dec 31 19:00:00 1969 (which not 1389396780). can 1 help me out why it's not printing out proper date/time?

<i>#include <stdio.h> #include <stdlib.h> #include <time.h> typedef struct { char flightnum[7]; // +1 due null char originairport[5]; char destairport[5]; long time; }flightdata; // function flight number void fofflightnum(flightdata*); int main() { int = 0; time_t c; flightdata flights[30000]; file* binfile; binfile = fopen("acars.bin", "rb"); if(binfile == null) { printf("sorry, can't open!\n"); exit(-1); } while (!feof(binfile)) { fgets(&flights[i].flightnum, 7, binfile); fseek(binfile, 1, seek_cur); fgets(&flights[i].originairport, 5, binfile); fseek(binfile, 1, seek_cur); fgets(&flights[i].destairport, 5, binfile); fseek(binfile, 4, seek_cur); fread(&flights[i].time, 1, sizeof(long), binfile); c = strtoul( "flights[i].time", null, 0 ); ctime( &c ); printf("%s %s %s %ld\n", flights[i].flightnum, flights[i].originairport, flights[i].destairport, flights[i].time); i++; printf("%s", ctime( &c )); system("pause"); } fclose(binfile); homecoming 0; }

i able solve it, right coding

c = flights[i].time; ctime( &c );

epoch

No comments:

Post a Comment