我有一个代码:
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
cout<<"Hello World!";
getch();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我能收回字符串"Hello World!" 在一些char或字符串变量?
Ker*_* SB 11
不,但您可以使用字符串流来实现这种效果:
#include <iostream>
#include <sstream>
std::ostringstream oss;
oss << "Hello World!";
std::cout << oss.str();
Run Code Online (Sandbox Code Playgroud)
现在oss.str()仍然包含您构建的字符串.
| 归档时间: |
|
| 查看次数: |
72 次 |
| 最近记录: |