Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a hex string to an unsigned long?

I have following hex value

CString str;
str = T("FFF000");

How to convert this in to an unsigned long?

like image 509
Vikram Ranabhatt Avatar asked Nov 30 '22 04:11

Vikram Ranabhatt


1 Answers

You can use strtol function which works on regular C strings. It converts a string to a long using a specified base:

long l = strtol(str, NULL, 16);

details and good example: http://www.cplusplus.com/reference/clibrary/cstdlib/strtol/

like image 72
Adam Avatar answered Dec 05 '22 14:12

Adam