Re: CString hex value to CString decimal value



Simply use:

char *pEnd;
unsigned long ulNumber = strtoul("93d2f666", &pEnd, 16);
CString str;
str.Format("%x", ulNumber);

"Alex" <alex@xxxxxxxxx> wrote in message
news:42e13b25$0$751$5fc3050@xxxxxxxxxxxxxxxxxxxxxxxxxxx
> Please bare with me, I am quite new to C++.
>
> A CString contains a (large) hexadecimal string value,
> this value needs to be converted to an decimal value,
> and then put back as a string into an other CString.
>
> Data example: hexadecimal: 93d2f666 = decimal 2480076390
>
> I have googled and found a lot of solutions (hex string to int)
> but none of them returns the correct decimal value, I suspect
> that converting a large hex string to int does not work.
>
> So if someone could point me to the right direction or
> could suply a working sample, please do.
>
> TIA
>
> Alex
>
>
>
>
>
>


.



Relevant Pages

  • Re: peer code review/advice needed for noob programmer
    ... There are lots of easy ways to transition from char to CString; ... Yes, except I am having to program to Microsoft FS's API, and the string is ... if any reason to allocate a buffer here. ...
    (microsoft.public.vc.mfc)
  • Re: CSocket/CAsyncSocket sending and receiving
    ... Stop experimenting with CSocket; it is losing. ... CString constructor will do a MultiByteToWideChar to convert the string. ... sequence of Receives will receive N bytes. ...
    (microsoft.public.vc.mfc)
  • Re: CFileDialog drives me insane. Handle Problem ?
    ... The basic type you care about is CString. ... This is the equivalent to the Java 'String' ... There are rare cases in which you need a LPTSTR pointer, ... const wchar_t * - const pointer to Unicode characters. ...
    (microsoft.public.vc.mfc)
  • Re: String tokenizer for CString?
    ... I needed to be able to split a string that had double quotes and multiple delimiters. ... void SplitPath(BOOL UsingDirsOnly, CString Path, CString& Drive, CString& ... Splits a CString into an CStringArray according the Deliminator. ... int SplitLine; ...
    (microsoft.public.vc.mfc)
  • Re: Binary to Hexadecimal Conversion
    ... Introducing objects might be nice as well, but I suspect this is an exercise pretty early in your class. ... The loop converting the binary string to an int should be an int-valued function with a string argument. ... It might also be nice to detect overflow here and give an error if the user enters something too large for an int. ... A 20 digit hex string is far larger than the maximum int value, so you'll always have leading zeros with this process unless you detect them and don't print them. ...
    (comp.lang.java.programmer)