what is the difference between getch() & getche()

?

=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=

srikanth said:
i am right to what i meant sir it is getche ( )and not getchar( )

neither getch or getche are standard functions.
You need to explain where you discovered those function, or probably
ask in an OS dependant newsgroup.
 
V

Vladimir S. Oka

srikanth said:
Nils O. Selåsdal
neither getch or getche are standard functions
my reply :getch( ) and getche( ) are pre defined functions in C LANG.
:they are under the headerfile <conio.h>

My reply: you are a troll. Goodbye...
 
S

srikanth

Nils O. Selåsdal
neither getch or getche are standard functions
my reply :getch( ) and getche( ) are pre defined functions in C LANG.
:they are under the headerfile <conio.h>
 
V

Vladimir S. Oka

srikanth said:
i am right to what i meant sir it is getche ( )and not getchar( )

1. Quote what a nd who you're replying to.
2. Be polite when asking for help.
3. One is standard C, the other one isn't.
4. Go figure.
 
M

Martin Ambuhl

srikanth said:
help me out with the subject

Repeated for those who don't bother with subject headers, knowing that
they are meaningless and are not the place to put important parts of posts:
what is the difference between getch() & getche()

From the point of view of C, none. They are undefined identifiers
denoting some function or the other. Neither is part of C. Similarly
named functions (or possibly macros) in C are fgetc(), getc(), and
getchar().
 
B

B. P. TBC

srikanth írta:
help me out with the subject
getch(): reads a char from the keyboard. It doesn't echoes it to the screen.
getche(): reads a char from the keyboard and echoes it to screen.
 
I

Ian Collins

srikanth said:
Nils O. Selåsdal
neither getch or getche are standard functions
my reply :getch( ) and getche( ) are pre defined functions in C LANG.
:they are under the headerfile <conio.h>
Which isn't a standard header, you'll have to ask in a platform specific NG.
 
R

Randy Howard

srikanth wrote
(in article
i am right to what i meant sir it is getche ( )and not getchar( )

No you are not, at least not in terms of standard C. I think
you are referring to an abomination provided by Microsoft. If
so, the incredibly helpful (ahem) MSDN should tell you enough to
make you dangerous.
 
R

Randy Howard

srikanth wrote
(in article
Nils O. Selåsdal
neither getch or getche are standard functions
my reply :getch( ) and getche( ) are pre defined functions in C LANG.

No, they are not.
:they are under the headerfile <conio.h>

That is a "predefined" and "nonstandard" header. Just because
your chosen compiler provides additional interfaces does NOT
make it part of standard C.
 
R

Randy Howard

B. P. TBC wrote
(in article said:
srikanth írta:
getch(): reads a char from the keyboard. It doesn't echoes it to the screen.
getche(): reads a char from the keyboard and echoes it to screen.

Wrong. My version of getch(), which I am free to implement as I
see fit since it is not in standard C, calculates the sqrt of 4
over and over again, just because I find that fun to do.
getche() reboots my computer, but only after asking whether or
not I want to wipe out the partition table first.
 
M

Martin Ambuhl

B. P. TBC said:
srikanth írta:

getch(): reads a char from the keyboard. It doesn't echoes it to the
screen.
getche(): reads a char from the keyboard and echoes it to screen.

Who says so? Where in the standard is this behavior specified? For
that matter, where in the standard are these "keyboard" and "screen"
discussed?[1]

[1] <ot> Having just checked my collection of standards other than for
C, I see that the Fortran 77 (but not Fortran 66) standard mentions a
"keyboard" in passing once, but never a "screen". </ot>
 
M

Mark McIntyre

On Sun, 5 Mar 2006 20:05:43 +0000 (UTC), in comp.lang.c ,
I've never heard of getche(). Did you perhaps mean getchar() ?

Its some ancient borland extension to C.

To the OP: read your compiler documentation. Neither function is a
standard C function and we can't help you here.
Mark McIntyre
 
C

CBFalconer

B. P. TBC said:
srikanth írta:

getch(): reads a char from the keyboard. It doesn't echoes it to
the screen.
getche(): reads a char from the keyboard and echoes it to screen.

You are aiding and abetting a troll. Because of the misinformation
in your reply (neither function is mentioned in the standard) I
offer the following implementations:

#define choke continue

/* get and choke */
int getch(void) {
volatile int ch;
ch = getchar();
while (ch) choke;
return ch;
}

/* get and choke on e */
int getche(void)
volatile int ch;
ch = getchar();
while ('e' == ch) choke;
return ch;
}

Just compile and use these and you should be all set, and standards
compliant to boot.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
 
R

Rod Pemberton

srikanth said:
help me out with the subject

They are DOS console IO functions. getche() displays the character on the
screen. getch() doesn't.
A complete Borland C++ reference is available here:
http://poli.cs.vsb.cz/c/help/index


i.e., to see getche() click "C++ Language", click "conio.h", click "getche".
Under "Portability", you'll see that the function is DOS only.


Rod Pemberton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top