System.AnsiStringT.c_str
C++
char* c_str() const {
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | dstring.h | System | AnsiStringT |
Description
Returns the AnsiStringT converted to a null-terminated character array.
c_str returns a pointer to a null-terminated character array containing the same characters as the AnsiStringT. If the AnsiString is unassigned, c_str returns an empty string (“”).
Usually, the value returned by 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 c_str method is intended primarily for reading the value of the AnsiString. To modify the string’s value, use the [] operator or AnsiStringT methods such as Insert and Delete.