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

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply   View First Unread View First Unread

Join Date: Nov 2005
Posts: 39
Reputation: comwizz is an unknown quantity at this point 
Solved Threads: 0
comwizz's Avatar
comwizz comwizz is offline Offline
Light Poster

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

 
0
  #1
Dec 27th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,363
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 242
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

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

 
0
  #2
Dec 27th, 2005
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.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 39
Reputation: comwizz is an unknown quantity at this point 
Solved Threads: 0
comwizz's Avatar
comwizz comwizz is offline Offline
Light Poster

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

 
0
  #3
Dec 29th, 2005
Thanks for the reply
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 2
Reputation: pavangavvala is an unknown quantity at this point 
Solved Threads: 0
pavangavvala pavangavvala is offline Offline
Newbie Poster

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

 
-1
  #4
May 24th, 2009
wat is echo??
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,730
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 737
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

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

 
2
  #5
May 24th, 2009
>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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 2
Reputation: pavangavvala is an unknown quantity at this point 
Solved Threads: 0
pavangavvala pavangavvala is offline Offline
Newbie Poster

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

 
0
  #6
May 25th, 2009
Originally Posted by Narue View Post
>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......
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 9
Reputation: rocky2008 is an unknown quantity at this point 
Solved Threads: 0
rocky2008 rocky2008 is offline Offline
Newbie Poster

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

 
0
  #7
May 27th, 2009
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 !!

Originally Posted by comwizz View 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.
Regards,
Rocky.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,033
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 177
Aia's Avatar
Aia Aia is offline Offline
Postaholic

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

 
1
  #8
May 27th, 2009
Rocky2008> hope you understood!!
What part of post #2 did you not understand?
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 10
Reputation: patria987 is an unknown quantity at this point 
Solved Threads: 0
patria987 patria987 is offline Offline
Newbie Poster

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

 
0
  #9
May 29th, 2009
Originally Posted by comwizz View 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.
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)
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,033
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 177
Aia's Avatar
Aia Aia is offline Offline
Postaholic

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

 
1
  #10
May 29th, 2009
Originally Posted by pavangavvala View Post
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.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC