Convert char* to string C++

后端 未结 5 2009
轮回少年
轮回少年 2021-01-31 03:29

I know the starting address of the string(e.g., char* buf) and the max length int l; of the string(i.e., total number of characters is less than or equ

5条回答
  •  轮回少年
    2021-01-31 04:08

    char *charPtr = "test string";
    cout << charPtr << endl;
    
    string str = charPtr;
    cout << str << endl;
    

提交回复
热议问题