简体   繁体   中英

c convert uint32_t casted to int32 saved to file and read the uint32_t agein

I have made a C program to log some data.
I get a timestamp in uint32_t format.
I then saved the data using afprintf("%d",timestamp) this means that it made a cast from the unsigned integer to an signed integer, and therefore i got some numbers which are way of.
My question is then. how do i compute it back to the original unsigned integer. preferable in ac# program. but anything will do.

why not save it with fprintf("%u",timestamp) which is meant for unsigned ints?

but casting in general is done like this:

    unsigned int a;
    int b = -1;

    a = (unsigned int )b;  // a should now be 4294967295

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM