繁体   English   中英

c将转换为int32的uint32_t转换为保存到文件并读取uint32_t agein

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

我做了一个C程序来记录一些数据。
我得到了uint32_t格式的时间戳。
然后,我使用afprintf(“%d”,timestamp)保存了数据,这意味着它从无符号整数到有符号整数进行了强制转换,因此我得到了一些数字。
我的问题是。 我如何将其计算回原始的无符号整数。 在ac#程序中更可取。 但是一切都会做。

为什么不使用fprintf(“%u”,timestamp)来保存它,它用于无符号整数?

但一般来说,投射是这样完成的:

    unsigned int a;
    int b = -1;

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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