Вопрос

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:

#include <stdio.h>

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

or strtoull:

#include <stdlib.h>

address = (unsigned int *)strtoull(array, NULL, 0);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top