RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
UnicodeString::c_str Method

Returns a pointer to the underlying string System::UnicodeString::data as const wchar_t*.

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

System::UnicodeString::c_str returns a wchar_t pointer to the location in memory where the value of the System::UnicodeString object is stored. If the System::UnicodeString is unassigned, System::UnicodeString::c_str returns a wchar_t pointer to the empty string (“”). 

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

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

The System::UnicodeString::t_str method returns const char* for backward compatiblity with the VCL and to preserve narrow data

 

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