Hi
can someone pls tell me, in mfc, how do I obtain the ascii value of a CString object
eg
CString cs ="Ac20"
how do I get the ascii value of each char in the string?
Thanks
Printable View
Hi
can someone pls tell me, in mfc, how do I obtain the ascii value of a CString object
eg
CString cs ="Ac20"
how do I get the ascii value of each char in the string?
Thanks
You can use either the GetAt() function or the subscript [] operator. Here's more info on CString.
You can simple assign the char to a int variable
You can display the hex value as well using %x in a string
Hope this helps.Code:CString szString = "Ac20";
int nValue;
nValue = szString[0]; // nValue will store a value of 65, which is the ASCII value for 'A'
CString szMsg;
szMsg.Format("%d %02x", b, b); // szMsg will appear as "65 41"