ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • c_str
    C++ Builder/함수 2018. 12. 6. 22:06

    #c_str


    string 문자열을 문자형 포인터로 변환하는데 사용된다.

    System.UnicodeString.c_str

     

    C++

    WideChar* c_str() const   { return (Data)? Data: const_cast<WideChar*>(L"");}

    Properties

    Type

    Visibility

    Source

    Unit

    Parent

    function

    public

    ustring.h

    System

    UnicodeString

    Description

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

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

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

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

    ex) {

    UnicodeString TestString = “Test String”;

    char * TestChar = TestString.c_str();

    ShowMessage(TestChar);

    }



    728x90

    'C++ Builder > 함수' 카테고리의 다른 글

    Pos  (0) 2018.12.06
    Delete  (0) 2018.12.06
    Insert  (0) 2018.12.06
    Length  (0) 2018.12.06
    sprintf  (0) 2018.12.06

    댓글

Designed by Tistory.