使用istream_iterator进行复制 [英] Copying with istream_iterator

查看:111
本文介绍了使用istream_iterator进行复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



------ foo.cpp:BEGIN ------

#include< cassert>

#include< vector>

#include< string>

#include< iostream>

#include< iterator>

#include< fstream>

使用命名空间std;

int main()

{

ifstream f(foo.in,ios_base :: binary);

断言(f);

istream_iterator< string> b(f),e;


cout<< "(1)文件:" ;;

copy(b,e,ostream_iterator< string>(cout,""));

cout<< ; endl;


cout<< (2)文件:" ;;

copy(b,e,ostream_iterator< string>(cout,""));

cout<< ;结束;


返回0;

}

------ foo.cpp:END ----- ---

------编译&运行:BEGIN ------


$ g ++ - version

g ++(GCC)3.3.1(cygming special)

[---省略---]

$ g ++ -mno-cygwin foo.cpp


$ a

(1)文件:abc xyz ijk pqr

(2)文件:abc


------编译&运行:END --------


为什么两个copy()产生不同的输出?

-

Alex Vinokur
http://mathforum.org/ library / view / 10978.html
http://sourceforge.net / users / alexvn


------ foo.cpp : BEGIN ------
#include <cassert>
#include <vector>
#include <string>
#include <iostream>
#include <iterator>
#include <fstream>
using namespace std;
int main ()
{
ifstream f("foo.in", ios_base::binary);
assert (f);
istream_iterator<string> b(f), e;

cout << "(1) File : ";
copy (b, e, ostream_iterator<string> (cout, " "));
cout << endl;

cout << "(2) File : ";
copy (b, e, ostream_iterator<string> (cout, " "));
cout << endl;

return 0;
}
------ foo.cpp : END --------
------ Compilation & Run : BEGIN ------

$ g++ --version
g++ (GCC) 3.3.1 (cygming special)
[---omitted---]
$ g++ -mno-cygwin foo.cpp

$ a
(1) File : abc xyz ijk pqr
(2) File : abc

------ Compilation & Run : END --------

Why do two copy()''s produce different output?
--
Alex Vinokur
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

推荐答案

g ++ --version

g ++(GCC)3.3 .1(cygming special)

[---省略---]
g++ --version
g++ (GCC) 3.3.1 (cygming special)
[---omitted---]


g ++ -mno-cygwin foo.cpp

g++ -mno-cygwin foo.cpp


a

(1)文件:abc xyz ijk pqr

(2)文件:abc


------编译&运行:END --------


为什么两个copy()产生不同的输出?

-

Alex Vinokur
http://mathforum.org/ library / view / 10978.html
http://sourceforge.net / users / alexvn

a
(1) File : abc xyz ijk pqr
(2) File : abc

------ Compilation & Run : END --------

Why do two copy()''s produce different output?
--
Alex Vinokur
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn


这篇关于使用istream_iterator进行复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆