上面的代码将string类型数据str转换为char数组buffer。 除了上述方法,还可以使用stringstream类来实现char数组和string类型数据之间的转换。例如: ```c #include #include char str[20] = "Hello"; std::stringstream ss; std::string result; ss << str; ss >> result; ``` 上面的代码使用stringstream类将cha...