Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows analog to UNIX atoh() function

Tags:

windows

mfc

Is there in Windows API or in MFC any analog to atoh() function?

atoh() converts a string containing a hexadecimal number into an unsigned number like

unsigned x = atoh("A");

and x = 10 after the operation.

In Windows I have a CString, containing "A". How can I convert it to int?

like image 396
Nick Borodulin Avatar asked Mar 02 '23 03:03

Nick Borodulin


2 Answers

long x = strtoul("A", (char **) NULL, 16);
// x will be 10 decimal
like image 139
activout.se Avatar answered Mar 31 '23 07:03

activout.se


unsigned long ten = strtoul("a", NULL, 16); should handle it, if you can get a plain old char *-representation out of the CString. The accepted solution using strtoul() does a signed conversion.

like image 42
unwind Avatar answered Mar 31 '23 05:03

unwind