首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

Ctrl+z 模拟文件尾,如何样让输出窗口停留一段时间呢

2012-09-16 
Ctrl+z 模拟文件尾,怎么样让输出窗口停留一段时间呢?编写一个程序,从标准输入读取多个string对象,把他们连

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

热点排行