String "0x?" to a uint_16

how to convert a string to uint_16, im doing a mini c64 on uno using my ST7789 LCD, i have string "0x????" and i need to convert it to a uint_16 i check others but i cant find solution does somewone know how to do this?

Use the strtol() function.

long int strtol (const char* str, char** endptr, int base);

Set the second argument to 0 if you don't need a pointer to the first character after the number.

Set the third argument to 0 to let the library recognize the "0x" part and automatically chose HEX.

A reference for some other string (null terminated character array) to number conversion functions including strtol().

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.