关于eof的疑惑

关于eof的疑惑
#include  " stdafx.h "
#include 
< iostream >
#include 
< fstream >
#include 
< iterator >
#include 
< algorithm >
#include 
< vector >
#include 
< string >

using   namespace  std;

int  main()
{
    ifstream in_file( 
"input_file.txt" );
    ofstream out_file( 
"output_file.txt" );
    
    
if ( ! in_file || ! out_file )
    
{
         cerr
<<"!!unable to open the necessary files.\n";
         
return -1;
    }

    
    istream_iterator
< string > is( in_file );
    istream_iterator
< string > eof;
    
    vector 
< string > text;
    copy( 
is, eof, back_inserter( text ));
    
    sort( text.begin(), text.end() );
    
    ostream_iterator
< string > os( out_file," " );
    copy( text.begin(), text.end(), os );
}
代码如上,是<<Essential C++>>中的一段
input_file的内容为"7 956 1 5 147 3 78 24 87 62 45 12 77 86 64 52 58 74"
执行后
output_file中内容为"1 12 147 24 3 45 5 52 58 62 64 7 74 77 78 86 87 956"

- -
sort()对字符串排序...shit...只认首字符

你可能感兴趣的:(关于eof的疑惑)