O
oliu321
I have the following code:
vector<int> A, B;
copy(istream_iterator<int>(cin), istream_iterator<int>(),
back_inserter(A));
copy(istream_iterator<int>(cin), istream_iterator<int>(),
back_inserter(B));
If I input the following
1 2 3 4 a <CR>
then I can get A as 1,2,3,4 which is OK, but then the second copy
won't read anything and the B becomes empty.
I can see that cin has bad bit set to true after the first copy which
it should be. But even after I called a cin.clear() before the second
copy, I still couldn't get the program to try to read my second line
of input into B. I guess somewhat you should tweak the cin to force
the second copy work. But how?
Thanks
Ou
vector<int> A, B;
copy(istream_iterator<int>(cin), istream_iterator<int>(),
back_inserter(A));
copy(istream_iterator<int>(cin), istream_iterator<int>(),
back_inserter(B));
If I input the following
1 2 3 4 a <CR>
then I can get A as 1,2,3,4 which is OK, but then the second copy
won't read anything and the B becomes empty.
I can see that cin has bad bit set to true after the first copy which
it should be. But even after I called a cin.clear() before the second
copy, I still couldn't get the program to try to read my second line
of input into B. I guess somewhat you should tweak the cin to force
the second copy work. But how?
Thanks
Ou