istream_iterator

Hello,
Can some one give me an example of using the istream_iterator under VC6.

Tank's
arnon@zzn.com
arnonayalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nietodCommented:
fstream Fil("GileName",ios::in);
istream_iterator Itr(Fil);

while (true)
{
   ++Itr; // get next item.
   if (Fil.eof())
      break;
   char Ch = *Itr; // Get item just read.
}

Its sort of like a pointer into the input stream.  You can get what it points at by using * or ->.  You can move it to the next item in the stream using ++.

Let me know if you have any questions.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arnonayalAuthor Commented:
Hello, Thanks to the fast response. I stiil have problem to compile it.
My code:
-------------------------------------
#include <iostream>
#include <fstream>
#include <iterator>

using namespace std;

void main(int argc, char* argv[])
{
      fstream Fil("GileName",ios::in);
      istream_iterator Itr(Fil);

      while (true)
      {
        ++Itr; // get next item.
            if (Fil.eof())
        break;
      char Ch = *Itr; // Get item just read.
      }
}

------------------------------------
I get errors:
C2955: 'istream_iterator' : use of class template requires template argument list(180) : see declaration of 'istream_iterator'
C2514: 'std::istream_iterator' : class has no constructors.

Thank's again, Arnon
0
nietodCommented:
stream_iterator Itr(Fil);

should be

stream_iterator<char> Itr(Fil);

That will fix the first problem and I hope the second one too.
0
arnonayalAuthor Commented:
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.