Not sure exactly what you're looking for. Some info and ideas:
The user can enter whatever he or she wants.
The terminal driver (or equivalent) will, by default, read whatever the user enters and hold it in a buffer. The contents of this buffer (again, by default) become available to cin after a newline character is entered.
cin will grab whatever you tell it to from the terminal driver's buffer; you can tell it to use what it grabs or to ignore what it grabs.
So you can ignore anything they've entered after the first character by calling cin.ignore. That's Standard.
You may also be able to tell the terminal driver (or equivalent) to behave in a manner different from its default.
That is, you could have it deliver every character to standard input (without waiting for a newline), so that after they enter the first character, you can output a message, or whatever you're trying to do to give the "feel" of only being able to enter one character.
The terminal driver may also have a mechanism to "stop" input until you flip a switch somewhere.
Controlling the terminal driver (or equivalent) is non-Standard (the Standard doesn't even require that there be a "screen"), so there are probably Windows API functions for controlling it.
You can use getch() or getche(), but unfortunately they are MS specific.
getc() is a C++ standard, but you need to press enter after you enter a character.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.