浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

xtoi (Hex to Integer) C function - Nanoseconds Network

xtoi (Hex to Integer) C function

Tuesday, June 20, 2006 6:06 PM by cvega

You mean "int to hex"?

Use sprintf:

char* output;
unsigned int value = 43981;
sprintf(output, "%X", value);

xtoi (Hex to Integer) C function - Nanoseconds Network

Edit:
From the comment below the page, you can see the C way of decoding hex from string using sscanf function:

unsigned int hex = 0;
const char* hexstr = "ABCD";

sscanf(hexstr, "%X", &hex);
printf("%s = %d\n", hexstr, hex);

posted on 2013-01-17 16:06  lexus  阅读(1044)  评论(0)    收藏  举报