Hi *!
I get from a lib a not null-terminated string back. I am want to copy it to my local std::string. I also get back the total length of C-string. Here is what i am doing
It works correctly but is it the corrrect way, coz if i don't null terminate the string i get some junk stuff (thats obvious) but the copying of string reads some part of memory that it is not supposed to. Whats the correct way to do that????????PHP Code:char* pChr = NULL;
short nChrLen = 0;
std::string szMyString = "";
// Call some lib functions with pChr and &nChrLen....
if(pChr){
szMyString = pChr;
szMyString[nChrLen] = '\\0';
}
Thanks in Advance,
Regards,
Usman.




Reply With Quote