t
does NOT equal '\n'
. It's empty. .get(char*,int)
will never remove the '\n'
from the buffer.
Worse, the attempt to read to t
will set cin
to a fail state since nothing could be read, which will cause all subsequent reads of any sort from cin
to fail immediately without even trying until you .clear()
the fail state.
This is surprising behavior, but you seem to have already guessed at most of it as per your last sentence in the question, so, Good Job! You're learning!