954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

reading a char from keyboard without pressing "Enter"???

Sorry for the nubbish question , but I'm wondering which function will do the trick-read a char from keyboard without need to press "Enter"???

jivosan
Newbie Poster
1 post since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

I know few old functions, but they are not standardised
getch() , getche

vishesh
Nearly a Posting Virtuoso
1,381 posts since Oct 2006
Reputation Points: 85
Solved Threads: 42
 

getchar() also.

Queatrix
Newbie Poster
13 posts since Mar 2007
Reputation Points: 10
Solved Threads: 1
 

getchar and getche functions just read a character, they serve no purpose in detecting when a key was pressed. You need to look into the kbhit function which detects keypresses and then read the character using getchar .

Read this. but mind you that the function is highly platform and compiler dependent.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

> but I'm wondering which function will do the trick-read a char from keyboard without need to press "Enter"
Yes there is, but not without you saying which OS / Compiler / application type (console, GUI etc) you're trying to write.

There isn't a standard "one way works for everyone" answer to this question.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You