unsigned long a = 0;
char b[] = “c0a801bb”;
a = strtol(b,NULL,16);
为嘛打印的值不对?怎么操作?
将16进制的8位字符串 转换成ip
char b[] = “c0a801bb”;
a = strtol(b,NULL,16);
为嘛打印的值不对?怎么操作?
将16进制的8位字符串 转换成ip
解决方案
40
int main() { char b[] = "c0a800bb"; unsigned int l; sscanf(b, "%8x", &l); printf("%x\n", l); return 0; }