Hi,
i am using some working code from an already existing example program. I use Visual C++ 2003. Here is the method i am using:
and when i run my program, i get "run-time check failure #2 - Stack around the variable 'cstr' was corrupted", which refers to the "char cstr[] =""; " of the method above i think. If i try to bypass the error, i also get "run-time check failure #2 - Stack around the variable 'hexval' was corrupted", which refers to the "byte hexval=0x00; ". The only differences -i have noticed so far- is that in my project, i use the "atlstr" header and my compiler and linker settings also differ from the example program... Any ideas?Code:void CIDAdmin::CStrToUchar(CString str, UCHAR *ucBuffer, ULONG *ulBufferLen) { int Length = 0; int DataLength = 0; char cstr[] =""; char strcstring[512] =""; byte hexval=0x00; int i = 0; Length = str.GetLength(); for (i = 0; i<Length; i++) strcstring[i] = str.GetAt(i); DataLength = Length / 2; for (i = 0; i<DataLength; i++) { cstr[0] = strcstring[2*i]; cstr[1] = strcstring[2*i+1]; sscanf( cstr, "%02x", &hexval ); ucBuffer[i]=hexval; } *ulBufferLen = DataLength; }//CStringToUchar
Thanks



LinkBack URL
About LinkBacks


