Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
String PitfallsDownloads: MS Windows Visual C/C++ Libraries Linux/CentOS C/C++ Libraries MAC OS X C/C++ Libraries Solaris C/C++ Libraries C++ Builder Libraries 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);
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.