How to convert the char array to unsigned int?
-
13-07-2021 - |
Question
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?
Solution
You could use sscanf
:
#include <stdio.h>
sscanf(array, "%p", &address);
or strtoull
:
#include <stdlib.h>
address = (unsigned int *)strtoull(array, NULL, 0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow