注册 登录
编程论坛 C++教室

请教关于流迭代器的问题

汪蜓 发布于 2011-09-26 20:12, 533 次点击
#include "iostream.h"    //for input/output
#include "vector.h"      //for vector
#include <string>
#include <algorithm>
using namespace std;

int main()
{
     vector<string> coll;

    copy(istream_iterator<string> (cin),    //start of source
       istream_iterator<string> (),       //end of source
       back_inserter(coll));              //destinatin

   sort(coll.begin(),coll.end());

   unique_copy(coll.begin(),coll.end(),                  //source
              ostream_iterator<string> (cout, "\n"));    //destination
}
代码如上,

我的问题就是:我该如何停止符号的输入呢?回车键之类的都用过了,但是就是没有办法结束符号的输入。

请各位指教一二,谢谢
(因为是注册新手,所以给分不是很多,请谅解
2 回复
#2
specilize2011-09-26 21:48
输完数据后按回车,在按Ctrl+Z,在回车,就显示出来了

[ 本帖最后由 specilize 于 2011-9-26 21:50 编辑 ]
#3
lucky5635912011-09-27 08:14
干嘛不加个输入判断
1