DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C (http://www.daniweb.com/forums/forum118.html)
-   -   Difference betn getch(),getche(),getchar() functions (http://www.daniweb.com/forums/thread37195.html)

comwizz Dec 27th, 2005 1:05 pm
Difference betn getch(),getche(),getchar() functions
 
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. :confused:

Dave Sinkula Dec 27th, 2005 1:29 pm
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.

comwizz Dec 29th, 2005 12:54 am
Re: Difference betn getch(),getche(),getchar() functions
 
Thanks for the reply :)

pavangavvala May 24th, 2009 9:13 am
Re: Difference betn getch(),getche(),getchar() functions
 
wat is echo??

Narue May 24th, 2009 9:42 am
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.

pavangavvala May 25th, 2009 4:54 am
Re: Difference betn getch(),getche(),getchar() functions
 
Quote:

Originally Posted by Narue (Post 875006)
>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......:)

rocky2008 May 27th, 2009 4:18 am
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 !! :)

Quote:

Originally Posted by comwizz (Post 182053)
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. :confused:


Aia May 27th, 2009 1:38 pm
Re: Difference betn getch(),getche(),getchar() functions
 
Rocky2008> hope you understood!!
What part of post #2 did you not understand?

patria987 May 29th, 2009 11:42 am
Re: Difference betn getch(),getche(),getchar() functions
 
Quote:

Originally Posted by comwizz (Post 182053)
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. :confused:

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)

Aia May 29th, 2009 12:03 pm
Re: Difference betn getch(),getche(),getchar() functions
 
Quote:

Originally Posted by pavangavvala (Post 874994)
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().


All times are GMT -4. The time now is 10:59 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC