using c++ is there any way to cout<<"plz help"<<endl; // only when the space bar is press not enter

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

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.