简体   繁体   English

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

[英]How to convert the char array to unsigned int?

I have the following code: 我有以下代码:

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

Please tell me, what is a correct way of writing the "array" value to "address" variable? 请告诉我,将“数组”值写入“地址”变量的正确方法是什么?

You could use sscanf : 您可以使用sscanf

#include <stdio.h>

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

or strtoull : strtoull

#include <stdlib.h>

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM