【问题标题】:Casting a uint** to a uint将 uint** 转换为 uint
【发布时间】:2013-04-24 17:23:34
【问题描述】:

我有以下代码

unsigned int headerbytes = 0U;
    headerbytes = (unsigned int*)strtoull(packet_space->header, NULL, 0);

    packetHeader header = deconstructPacketHeader((&headerbytes));

packet_space 是一个 char[],基本上它是一个 4 字节的 char 数组,我想将其转换为无符号整数。 deconstructPacketHeader() 采用无符号整数,但 stroutll (使用我的演员表)返回一个双指针。基本上,我如何获得 uint 的实际值(取消引用两次),以便我可以通过它做 deconstructPacketHeader() ?

谢谢!

【问题讨论】:

  • 如果packet_spacechar[],那么packet_space->header 怎么可能是一个有效术语?
  • 顺便说一句:我不知道你有什么奇怪的strtoull(),但是standard one 返回一个unsigned long long int
  • unsigned int * 分配给unsigned int???
  • packet_space->header的内容是什么?它是否包含带有数字文本表示的以空字符结尾的字符串,还是包含通过从网络流(或文件)读取而获得的四字节整数?

标签: c double-pointer


【解决方案1】:

可能你想的太复杂了。

试试

unsigned long long headerbytes = 0ULL;
headerbytes = strtoull(packet_space->header, NULL, 0);
packetHeader header = deconstructPacketHeader(headerbytes);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-05
    • 2012-11-06
    • 2014-07-31
    • 2016-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多