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:

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.

commented: Thank you.. :) +0

Thanks for the reply :)

wat is echo??

commented: echo is the sound you hear when you resurrect a thread which has been dead for over 3 years -6
commented: ... -2
commented: aww.. this was a legitimate question. +9
commented: I agree this was a legit question even when the thread was old. +16
commented: Start a new thread. -1
commented: It was maybe a legitimate question, but you could quickly have found the answer by Googling first!! (and if you were too lazy for that: by starting a new thread) -1

>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.

commented: print series 2,4,16,256..up to n in c lanuage +0

>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......:)

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 !! :)

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:

Rocky2008> hope you understood!!
What part of post #2 did you not understand?

commented: The age of the original post for one thing ;) +32

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)

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().

commented: In other words: unportable rubbish :P +7

By : Shravan Aras <EMAIL SNIPPED>
Another interesting application of the getCh() function.
Also from my experience i have observed that sometimes the program fails to stop at

scanf(...)

. This happens because there is already some existing value in the buffer. To avoid this one can use

getCh();

to first clear the buffer and then use scanf function.
I am not completely sure of this process but has worked for me more than 90% of the times.

Still not sure what exactly echo is tho

The Standard C work is getchar() , pronounced in <stdio. ... They are not Standard C capacities; they don't exist on all frameworks. getch peruses one keystroke from the console quickly, without trusting that the client will hit the Return key, and without repeating the keystroke. getche is the equivalent, then again, actually it echoes.

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.