Convert Hex(or any base) string to Int





8
Date Submitted Wed. Aug. 9th, 2006 6:12 AM
Revision 1 of 1
Helper bobbyrward
Tags C | conversion | CPlusPlus | hexadecimal
Comments 3 comments
Converts a string representation of a number with any base(binary, octal, decimal, hexadecimal, up to base 36) to a long int.

const char string[] = "0xDEADBEEF";
long hexNumber = strtol(string + 2, NULL, 16);
 

Bobby Ward

Bobby R Ward
---------------------
bobbyrward@gmail.com

Comments

Comments I don't see how . . .
Mon. Oct. 9th, 2006 10:34 AM    Scripter sehrgut
  Comments For what it's worth
Thu. Oct. 19th, 2006 10:55 AM    Helper bobbyrward
Comments itoa()
Mon. Oct. 9th, 2006 6:19 AM    Helper shell

Voting