读书人

Ctrl+z 模拟文件尾如何样让输出窗口

发布时间: 2012-09-16 17:33:16 作者: rapoo

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;     }
[解决办法]
探讨
谢谢 帮我解决了问题!

读书人网 >C++

热点推荐