Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
String Pitfalls
Pitfalls to avoid with CkString. CkString *pStr = new CkString; pStr->append("This is a test"); // This returns a const pointer to memory internal to the string // object. Do not use it after the string object has been deleted // or manipulated in any way because the pointer may be invalid. const char *temp = pStr->getAnsi(); // "temp" may now point to uninitialized memory, and may cause a crash. pStr->clear(); // This could crash.. printf("[%s]\n",temp); // Re-fetch the pointer. temp = pStr->getAnsi(); // This is now OK: printf("[%s]\n",temp); // Definitely don't want to use "temp" after this.... delete pStr; // "temp" now points to uninitialized memory, and may cause a crash. printf("[%s]\n",temp);
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.