Ctrl+z 模拟文件尾,怎么样让输出窗口停留一段时间呢?
编写一个程序,从标准输入读取多个string对象,把他们连接起来存放到一个更大的string对象中,并输出连接后的对象。
在return 前面加上 cin.get好像没用啊!好像程序无法在接受输入了 怎么办帮我改改!
#include <iostream>
#include <string>
using namespace std;
int main()
{
string result_str, str;
cout<<"Enter strings (Ctrl+z to end)"<<endl;
while(cin>>str)
{
result_str = result_str + str;
}
cout<<"string equal to the concatenation of thest strings is:"
<<endl<<result_str<<endl;
return 0;
}
[解决办法]
- C/C++ code
#include <iostream> #include <string> using namespace std; int main() { string result_str, str; cout <<"Enter strings (Ctrl+z to end)" <<endl; while(cin>>str) { result_str = result_str + str; } cout <<"string equal to the concatenation of thest strings is:" <<endl <<result_str <<endl; system("pause"); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!return 0; }
[解决办法]