T
tong
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;
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;