📜  将字符串转换为字符 c++ 代码示例

📅  最后修改于: 2022-03-11 14:44:53.949000             🧑  作者: Mango

代码示例2
// "std::string" has a method called "c_str()" that returns a "const char*"
// pointer to its inner memory. You can copy that "const char*" to a variable
// using "strcpy()".

std::string str = "Hello World";
char buffer[50];

strcpy(buffer, str.c_str());

std::cout << buffer;    //Output: Hello World

//POSTED BY eferion ON STACK OVERFLOW (IN SPANISH).