It is ridiculously difficult to make a copy of a stream object, partially because all the copy constructors and assignment operators are protected. O_o
I would suggest following Disch's advice: try copying all the data in cin without clearing it.
Quite. in_avail() is non-portable. It is part of the C++ standard, however the standard does not require that it returns what one would expect or even anything useful at all.
I found elsewhere on the net that if I have std::ios::sync_with_stdio(false); it would work, and indeed now it does. but what does std::ios::sync_with_stdio(false); do?