四个字节转换成long Int整形

#include <stdio.h>
int main(void)
{
	unsigned char array[4] = {"0x0","0x0","0x02","0xe7"};
	unsigned long num;
	num = 0;
	for(int i=0; i<sizeof(array); i++)
	{
		num<<=8;
		num |= array[i];
	}
	printf("num = %d",num);
	return 0;
}


转载自:http://www.cppblog.com/lzr/archive/2008/12/20/69913.aspx

你可能感兴趣的:(四个字节转换成long Int整形)