2013-04-24 88 views
-1

我有下面的代码铸造一个uint **为uint

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

    packetHeader header = deconstructPacketHeader((&headerbytes)); 

packet_space是char [],基本上它是一种4字节字符数组,我要转换为一无符号整型。 deconstructPacketHeader()需要一个unsigned int,但stroutll(用我的强制转换)返回一个双指针。基本上,我如何获得uint的实际值(解除引用两次),所以我可以通过它执行deconstructPacketHeader()?

谢谢!

+0

如果'packet_space'是'的char []',怎么能'packet_space-> header'是有效期? – glglgl 2013-04-24 17:25:56

+0

BTW:我不知道你有什么奇怪的'strtoull()',但[standard](http://linux.die.net/man/3/strtoull)返回一个'unsigned long long int'。 – glglgl 2013-04-24 17:27:16

+0

将'unsigned int *'赋值给'unsigned int'? – shinkou 2013-04-24 17:27:49

回答

1

可能你觉得太复杂了。

尝试

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