Hi,
I am reading a value from the DB & then I have to write it in a file. After reading from the DB I am storing the value in a CString variable. I have to convert it into long to write in the file. But my problem when I am converting it to long the data value is changing. I do not want that the same string must be written in the file. Can you suggest how can I do that. Ok for clarification below is the example what I want:
CString strTemp = "1002007003297417";
The above value should be stored like following:
long lngTemp = 1002007003297417;
so that I can write in the file by the following way:
ch=((lngTemp>>24) & 0xff);
strPayload.SetAt(0,ch);
ch=((lngTemp>>16) & 0xff);
strPayload.SetAt(1,ch);
ch=((lngTemp>>8) & 0xff);
strPayload.SetAt(2,ch);
ch=(lngTemp & 0xff);
strPayload.SetAt(3,ch);
If I use lngTemp=_atoi64(strTemp ); the value is changing to "0xef7e7689"
If I use lngTemp=atol(strTemp ); the value is changing to "0x7fffffff"
but I want the value should be remain as it is : 1002007003297417
Please suggest how can I do it.
Regards,
Start Free Trial