[英]How to convert a char array to a string?
使用 string 的c_str
函数然后执行strcpy
将 C++ string
转换为 char 数组非常简单。 然而,如何做相反的事情呢?
我有一个字符数组,如: char arr[ ] = "This is a test";
要转换回: string str = "This is a test
.
使用 string 的c_str
函数然后执行strcpy
将 C++ string
转换为 char 数组非常简单。 然而,如何做相反的事情呢?
我有一个字符数组,如: char arr[ ] = "This is a test";
要转换回: string str = "This is a test
.
使用 string 的c_str
函数然后执行strcpy
将 C++ string
转换为 char 数组非常简单。 然而,如何做相反的事情呢?
我有一个字符数组,如: char arr[ ] = "This is a test";
要转换回: string str = "This is a test
.
使用 string 的c_str
函数然后执行strcpy
将 C++ string
转换为 char 数组非常简单。 然而,如何做相反的事情呢?
我有一个字符数组,如: char arr[ ] = "This is a test";
要转换回: string str = "This is a test
.
使用 string 的c_str
函数然后执行strcpy
将 C++ string
转换为 char 数组非常简单。 然而,如何做相反的事情呢?
我有一个字符数组,如: char arr[ ] = "This is a test";
要转换回: string str = "This is a test
.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.