Mail Archives: djgpp/2002/08/12/03:49:15
On 10 Aug 2002, Alex Vinokur wrote:
> ============
> Windows 2000
> DJGPP 2.03
> gcc/gpp 3.1
> ============
>
>
> The code below has no problem with gcc/gpp 3.0.4.
>
> However it does have a problem with gcc/gpp 3.1.
>
> What has been changed concerning istream_iterator and ostream_iterator ?
>
> ######### C++ code : BEGIN #########
> // File t1.cpp
>
> #include <string>
> #include <vector>
> #include <sstream>
> #include <iostream>
> #include <fstream>
missing '#include <iterator>'
(I also have met this problem)
Andris
> using namespace std;
>
> // ==============================
> int main (int argc, char** argv)
> {
> string file_line;
>
> if (!(argc > 1))
> {
> cout << "FATAL ERROR !"
> << endl;
>
> cout << " Usage : "
> << argv[0]
> << " "
> << "<Data-File-Name>"
> << endl;
> return 1;
> }
> assert (argc > 1);
>
> ifstream fin (argv[1]);
> assert (fin);
>
>
> cout << endl;
> cout << "\t-----------------------" << endl;
> cout << "\t--- File " << argv[1] << endl;
> cout << "\t-----------------------" << endl;
>
> for (int i = 1; getline (fin, file_line); i++)
> {
> vector<string> file_vline;
> istringstream isstr (file_line.c_str ());
>
> copy(
> istream_iterator<string>(isstr),
> istream_iterator<string> (),
> back_inserter (file_vline)
> );
>
> cout << "\t Line#" << i << " ---> ";
> copy (
> file_vline.begin (),
> file_vline.end (),
> ostream_iterator<string> (cout, " # ")
> );
> cout << endl;
>
>
> } // while
>
> cout << "\t-----------------------" << endl;
>
> }
>
>
> ######### C++ code : END ###########
>
>
> ######### Compilation : BEGIN #########
>
> %gpp t1.cpp
>
> T1.CPP: In function `int main(int, char**)':
> T1.CPP:43: `istream_iterator' undeclared (first use this function)
> T1.CPP:43: (Each undeclared identifier is reported only once for each function
> it appears in.)
> T1.CPP:43: parse error before `>' token
> T1.CPP:52: `ostream_iterator' undeclared (first use this function)
> T1.CPP:52: parse error before `>' token
>
>
> ######### Compilation : END ###########
- Raw text -