Click to See Complete Forum and Search --> : How to i Convert Hex int Value.


rajesh_s76
May 21st, 2002, 02:06 AM
Hi,

How do i conver the Hex value to Integer value. for example
i am having the Hexvalue is "1E2EE"( for ex: int 30 = 1E(Hex Value ), int 750 = 2EE(hex vlaue) )

How do i Conver Hex to Int do that?...

CString csTemp = "1E2EE";

how do i convert to Int?...

any help pl.

i am using VC++,MFC

Rajesh. S

r_nagendra
May 21st, 2002, 02:31 AM
In order to convert a hex number stored in a String as like this


char str="1E2EE"; <- if this is the value we have

int val;
sscanf(str,"%x",&val); <- now val has an integer value taken from the string



This above code executes in all types of programing methods like MFC / C/C++ . And in the place of str variable in sscanf you can also have a dynamic string variable or type cast a CString object using (LPCSTR)

Regards
Nagendra