converting an int to a hex String
-
Hi, How can I convert an int (or a double) to a CString, wich contains a hex value. Example: I've got an int, called 'a', with value 33. And I need to get a String with the hexadeciaml value of 'a', wich means (in this case) that I need a CString containing "21". Do you know wether is some fkind of function for this??? Thanks
-
Hi, How can I convert an int (or a double) to a CString, wich contains a hex value. Example: I've got an int, called 'a', with value 33. And I need to get a String with the hexadeciaml value of 'a', wich means (in this case) that I need a CString containing "21". Do you know wether is some fkind of function for this??? Thanks
Here you go. As always thrown together and untested but should work.
int nValue = 33; CString str; str.Format("%x", nValue);
There are 10 types of people in the world Those who understand binary, and those who don't
-
Hi, How can I convert an int (or a double) to a CString, wich contains a hex value. Example: I've got an int, called 'a', with value 33. And I need to get a String with the hexadeciaml value of 'a', wich means (in this case) that I need a CString containing "21". Do you know wether is some fkind of function for this??? Thanks
See the FAQ 6.3 How can I change a number into its string representation, or vice versa? [^] --Mike-- Ericahist [updated Oct 26] | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer. -- Michael P. Butler in the Lounge
-
Hi, How can I convert an int (or a double) to a CString, wich contains a hex value. Example: I've got an int, called 'a', with value 33. And I need to get a String with the hexadeciaml value of 'a', wich means (in this case) that I need a CString containing "21". Do you know wether is some fkind of function for this??? Thanks
-
Hi, How can I convert an int (or a double) to a CString, wich contains a hex value. Example: I've got an int, called 'a', with value 33. And I need to get a String with the hexadeciaml value of 'a', wich means (in this case) that I need a CString containing "21". Do you know wether is some fkind of function for this??? Thanks
Hey u can use this : long str2hex(char *str) { long hwnd=0; char ch; ::CharUpperBuff(str,8); for(int i=0;i<8;i++) { ch = str[i]; if(ch>=48 && ch<=57) hwnd+=(ch-48)*1<<(4*(7-i)); else if (ch>=65 && ch<=70) hwnd+=(ch-65+10)*1<<(4*(7-i)); } return hwnd; } -Vladimir India:)