atch 0 Junior Poster in Training

Hi,
I'm trying to initialize string with iterators and something like this works:

ifstream fin("tmp.txt");
istream_iterator<char> in_i(fin), eos; //here eos is 1 over the end
string s(in_i, eos);

but this doesn't:

ifstream fin("tmp.txt");
istream_iterator<char> in_i(fin), eos(fin);/* here eos is at this same position as in_i*/
//moving eos forward
for (int i = 0; i < 20; ++i)
{
++eos;
}
//trying to initialize string with pair of iterators gives me "" result
string s(in_i, eos);

Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.