如何将char数组转换为unsigned int?

时间:2012-10-23 07:25:53

标签: c arrays pointers char unsigned-integer

我有以下代码:

volatile unsigned int * address;
char * array="0x10000008";

请告诉我,编写"数组"的正确方法是什么?值为"地址"变量?

1 个答案:

答案 0 :(得分:6)

您可以使用sscanf

#include <stdio.h>

sscanf(array, "%p", &address);

strtoull

#include <stdlib.h>

address = (unsigned int *)strtoull(array, NULL, 0);