| | |
Difference betn getch(),getche(),getchar() functions
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
getcharThis is a standard function that gets a character from the stdin.
getchThis is a nonstandard function that gets a character from keyboard, does not echo to screen.
getcheThis 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
•
•
Join Date: Jun 2008
Posts: 9
Reputation:
Solved Threads: 0
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 !!
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 !!
Regards,
Rocky.
Rocky.
•
•
Join Date: May 2009
Posts: 10
Reputation:
Solved Threads: 0
•
•
•
•
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.
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)
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().
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.
"If it moves, tax it. If it keeps moving, regulate it, and if it stops moving, subsidize it" - Ronald Reagan
![]() |
Similar Threads
- Code for Image Processing (C)
- replacement of getch() (C++)
- how to get the last key pressed without stopping the programm ? (C)
- C++ help for a newbie (C++)
Other Threads in the C Forum
- Previous Thread: Mysql C API and Asterisk AGI
- Next Thread: Scan Chars Into 2D Array
Views: 66021 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for C
#include * .net append array arrays bash binarysearch changingto char character cm copyanyfile copypdffile createprocess() database directory drawing dynamic execv feet fgets file floatingpointvalidation fork function functions getlogicaldrivestrin givemetehcodez global grade graphics gtkwinlinux histogram homework i/o ide include infiniteloop initialization input interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list looping loopinsideloop. lowest matrix meter microsoft mqqueue mysql oddnumber odf open openwebfoundation overwrite pause pdf pointer pointers posix power process program programming pyramidusingturboccodes read recursion recv recvblocked reversing segmentationfault single socket socketprogramming spoonfeeding standard strchr string student suggestions system test testing threads unix urboc user whythiscodecausesegmentationfault win32api windowsapi






