3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Duoas
0

some thing like

char userIn;
cin>>userIn;

if(isspace(userIn))
{
   cout<<"whatever message"<<endl;
}

isspace() comes from cstdlib or ccctype to early in the morning for remembering just google it and it will confirm


if you want it event driven then you will need something like a message loop in which you check the keyDown event for the space bar and print then.

hope this helps

Edited by Kanoisa: n/a

0

All user input is terminated by pressing the ENTER key. Users expect this.

If you want to get individual key presses, you must do an OS-specific thing: disable buffered input.

On Windows, use SetConsoleMode().
On POSIX, use tcsetattr().

Be sure that you only do this when the user expects it, and that you restore things to line-buffered input before your program terminates.

All this is a bit more complicated than you may think. The NCurses library is a good, cross-platform system for writing programs that do this kind of thing.

POSIX: http://www.gnu.org/software/ncurses/
Windows: http://pdcurses.sourceforge.net/
Getting Started: http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

Good luck!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.