RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
AnsiString::data Method

Returns a pointer to the underlying string System::AnsiString::data.

Pascal
function data: const void*;
C++
__fastcall const void* data() const;

System::AnsiString::data() returns a pointer a null-terminated character array that the System::AnsiString::AnsiString uses to store its value. This is the same value as the one returned by the c_str() method, except that System::AnsiString::data() returns a NULL pointer when the value is an empty string.

Note: Because System::AnsiString::data() returns NULL instead of an empty string, it is useful for C++ functions that expect either a valid (non-empty) char* or NULL:

AnsiString x;
ShellExecute(0, static_cast<const char*>(x.data()), "File.txt", NULL, NULL, SW_SHOW);

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!