Just one correction though, I am not sure of the 1st step but what I am
sure is before the message is flushed, the input iterator is
incremented. For example
cout << i++ << j++ << endl;//i++, j++ are all executed before message
is flushed out.
Thanks,
Satish
Satish wrote:
> This is similar to
> cout << *in_iter++;
>
> Basically 3 things happen here
> 1. cout << operator is passed the value
> 2, increment operation takes place
> 3. message is flushed to output stream.
>
> Tge problem is in the 2nd step when it increments and if it moves to
> beginning of next stream input after all buffer reading is completed
> and it goes to waiting state.
> , then the 3rd step is not executed
>
> Thanks,
> Satish
>
> tong wrote:
> > i have tried a program that it should show all words i typed, but it can't
> > e.g.
> > 1 2 3
> > 1 <--
> > 2 <--
> > it always miss the last one
> > then i continue to type
> > 4
> > 3 <-- it shows now !!
> >
> > However, if i change the loop into
> > while( in_iter != eof){
> > *out_iter++ = *in_iter;
> > ++in_ter;
> > }
> >
> > it will be fine, i don't know what happens to it.
> >
> >
> >
> > ************************************************** ***************
> > #include <iostream>
> > #include <iterator>
> > #include <string>
> >
> > using namespace std;
> >
> > int main()
> > {
> > ostream_iterator<string> out_iter(cout, "<\n");
> > istream_iterator<string> in_iter(cin), eof;
> >
> > while( in_iter != eof ){
> > *out_iter++ = *in_iter++;
> > }
> > return 0;
|