const char* / std::string 轉換

| 0 Comments| | 17:56
Categories:

const char* convert to std::string:

    const char *p = "Welcome to GeeksForGeeks";

    // Conversion of char* to std::string using =
    std::string str = p;

std::string convert to const char*:

    std::string str = "hello";
    const char* p = str.c_str();

ref:
Convert char* to std::string in C++ – GeeksforGeeks
c++ – convert unicode to char – Stack Overflow

#C++ #coding #convert #UTF8 #programming

Leave a Reply

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *