RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
AnsiStringT::c_str Method

Returns the System::AnsiStringT converted to a null-terminated character array.

Pascal
function c_str: char*;
C++
__fastcall char* c_str() const;

System::AnsiStringT::c_str returns a pointer to a null-terminated character array containing the same characters as the System::AnsiStringT. If the AnsiString is unassigned, c_str returns an empty string (“”). 

Usually, the value returned by System::AnsiStringT::c_str points to the internal character array referenced by the data property. This pointer is valid until the string is next modified (for example when the SetLength method is called or the AnsiString goes out of scope). However, if the internal array is NULL, c_str() returns a pointer to a string literal.  

The System::AnsiStringT::c_str method is intended primarily for reading the value of the AnsiString. To modify the string’s value, use the [] operator or System::AnsiStringT methods such as Insert and Delete

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!