Cin one character at a time

I am trying to make a program that inputs one char at a time using cin. I'm using a loop with a set count and each loop should gather one char.

cin >> char;

What I want though, is for the cin to terminate and the entire loop to iterate again when the user hits the spacebar instead of them having to press enter. The input would then look like:

a b c e

Where each character represents another loop iteration. How would I get cin to do this? Thanks.
You can't. Standard I/O streams (cin) only allows input to be processed after the user hits enter.

If you want to get around that you have to use an external lib (like ncurses), a nonstandard lib (like conio), or a platform specific lib (like WinAPI).
Can I simulate this then, where when they hit enter, I don't actually go to the next line, I keep it on the current line and print a space to separate it? I'd like to prevent the input from looking like this at least:

a
b
c
e

Thanks for your reply.
bump
Not with cin, no. You'd have to use another lib.
@LostProject
To put the inputs all on one line, try looking here for an idea.
http://cplusplus.com/forum/general/51271/
You should be able to adapt it to your use.
Topic archived. No new replies allowed.