943,752 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 131591
  • C RSS
You are currently viewing page 1 of this multi-page discussion thread
Dec 27th, 2005
-1

Difference betn getch(),getche(),getchar() functions

Expand Post »
I would like to know what is the difference betn
getchar(),getch(), and getche() functions and which should be used in which conditions.
Thanks,
comwizz.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
comwizz is offline Offline
39 posts
since Nov 2005
Dec 27th, 2005
0

Re: Difference betn getch(),getche(),getchar() functions

getchar
This is a standard function that gets a character from the stdin.

getch
This is a nonstandard function that gets a character from keyboard, does not echo to screen.

getche
This is a nonstandard function that gets a character from the keyboard, echoes to screen.

Use getchar if you want it to work on all compilers. Use getch or getche on a system that supports it when you want keyboard input without pressing [Enter].

And note that the return value of all three is int! You need this to properly check for EOF.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Dec 29th, 2005
0

Re: Difference betn getch(),getche(),getchar() functions

Thanks for the reply
Reputation Points: 10
Solved Threads: 0
Light Poster
comwizz is offline Offline
39 posts
since Nov 2005
May 24th, 2009
-1

Re: Difference betn getch(),getche(),getchar() functions

wat is echo??
Reputation Points: 31
Solved Threads: 0
Newbie Poster
pavangavvala is offline Offline
2 posts
since May 2009
May 24th, 2009
1

Re: Difference betn getch(),getche(),getchar() functions

>wat is echo??
In this case, echo means that when you type a character, it prints to the screen so you can see what you typed.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
May 25th, 2009
0

Re: Difference betn getch(),getche(),getchar() functions

Click to Expand / Collapse  Quote originally posted by Narue ...
>wat is echo??
In this case, echo means that when you type a character, it prints to the screen so you can see what you typed.
THANK U NARUE......
Reputation Points: 31
Solved Threads: 0
Newbie Poster
pavangavvala is offline Offline
2 posts
since May 2009
May 27th, 2009
0

Re: Difference betn getch(),getche(),getchar() functions

getch() returns the character you typed without displaying it on the screen.
getche() returns the character you typed by displaying(echoing) it on the screen.
and finally, getchar() works similarly and echos the character that u typed on the screen after "enter" is given.
hope you understood!!
all the best !!

Click to Expand / Collapse  Quote originally posted by comwizz ...
I would like to know what is the difference betn
getchar(),getch(), and getche() functions and which should be used in which conditions.
Thanks,
comwizz.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rocky2008 is offline Offline
9 posts
since Jun 2008
May 27th, 2009
1

Re: Difference betn getch(),getche(),getchar() functions

Rocky2008> hope you understood!!
What part of post #2 did you not understand?
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006
May 29th, 2009
0

Re: Difference betn getch(),getche(),getchar() functions

Click to Expand / Collapse  Quote originally posted by comwizz ...
I would like to know what is the difference betn
getchar(),getch(), and getche() functions and which should be used in which conditions.
Thanks,
comwizz.
getche-displays the character that u have typed on the screen
getch-just returns the character that had been typed without displaying on the screen.
getchar-works similar as getche but needs an ENTER followed by the char typed...(macro version)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
patria987 is offline Offline
9 posts
since May 2009
May 29th, 2009
1

Re: Difference betn getch(),getche(),getchar() functions

wat is echo??
The experience you get from people posting the same, over and over, in this thread.

People! this thread has been answered since post number two. And the only thing it could be added to it might be that unless you have a compelling reason to handicap your code with none standard functions, do not use getche() or getche().
Last edited by Aia; May 29th, 2009 at 12:11 pm.
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Initialized and Uninitialized Global Variables
Next Thread in C Forum Timeline: my c source file can't be build by mingw when i'm using eclipse





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC