You can use cin.get()
to read each individual characters from the stream.
WaltP commented: OP asked for what he's doing wrong, not just code that fixes the problem. -3
anishakaul commented: Very helpful link. +2
Onlineshade commented: Good post. +0
matthewkeating commented: Thank you! Awesome answer. +1