0

I have this structure :

UID (4 byte unsigned integer)
Message size (4 byte unsigned integer)
Date (4 byte time_t value)

In a file I have this data :

UID : 3C 05 00 00
Message size : 2F EA 02 00
Date : FA 11 02 53

I dont find how get each value in human reading ? Can you help me please ?

Normally the size is 8581o and the date 02-17-2014 14:39.

user2705397
  • 61
  • 1
  • 6
  • 2
    Start by reading about [`fscanf`](http://en.cppreference.com/w/c/io/fscanf), then read more about the bitwise or and shift operators. – Some programmer dude Feb 20 '14 at 18:54
  • 1
    Perhaps your answer is already here .http://stackoverflow.com/questions/10324/how-can-i-convert-a-hexadecimal-number-to-base-10-efficiently-in-c – Coldsteel48 Feb 20 '14 at 18:55
  • I'm sorry but I dont understand I'm not a C developper... I just want to decode only this data for a check... – user2705397 Feb 20 '14 at 19:44
  • So why the tag `C`, then? You need someone to write you a decoder? – Jongware Feb 20 '14 at 21:10
  • No just someone explain me how C store this data. Normaly FA110252 is 4195418706 in base 10. Date is a time_t so a timestamp if I understand. This value converted is not the good date 5/11/1966 20:36:50 – user2705397 Feb 20 '14 at 21:40

1 Answers1

0
#include <stdio.h>
#include <time.h>

int main(int argc, char **argv) {
    unsigned u = 0x530211FA;// little endian
    time_t t = (time_t)u;//sizeof(u) == sizeof(t) ?
    printf("%s\n", ctime(&t));//Mon Feb 17 22:43:22 2014
    return 0;
}
BLUEPIXY
  • 39,699
  • 7
  • 33
  • 70