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

Discussion in 'C Programming' started by srikanth, Mar 5, 2006.

  1. srikanth

    srikanth Guest

    help me out with the subject
     
    srikanth, Mar 5, 2006
    #1
    1. Advertising

  2. In article <>,
    srikanth <> wrote:
    >help me out with the subject


    I've never heard of getche(). Did you perhaps mean getchar() ?

    --
    Is there any thing whereof it may be said, See, this is new? It hath
    been already of old time, which was before us. -- Ecclesiastes
     
    Walter Roberson, Mar 5, 2006
    #2
    1. Advertising

  3. srikanth

    srikanth Guest

    i am right to what i meant sir it is getche ( )and not getchar( )
     
    srikanth, Mar 5, 2006
    #3
  4. srikanth wrote:
    > 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.
     
    =?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=, Mar 5, 2006
    #4
  5. srikanth wrote:

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

    --
    BR, Vladimir

    I prefer rogues to imbeciles because they sometimes take a rest.
    -- Alexandre Dumas the Younger
     
    Vladimir S. Oka, Mar 5, 2006
    #5
  6. srikanth

    srikanth Guest

    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>
     
    srikanth, Mar 5, 2006
    #6
  7. srikanth wrote:

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

    --
    BR, Vladimir

    Don't be overly suspicious where it's not warranted.
     
    Vladimir S. Oka, Mar 5, 2006
    #7
  8. srikanth wrote:
    > 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().
     
    Martin Ambuhl, Mar 5, 2006
    #8
  9. srikanth

    B. P. TBC Guest

    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.
     
    B. P. TBC, Mar 5, 2006
    #9
  10. srikanth

    Ian Collins Guest

    srikanth wrote:
    > 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.

    --
    Ian Collins.
     
    Ian Collins, Mar 5, 2006
    #10
  11. srikanth

    Jordan Abel Guest

    On 2006-03-05, srikanth <> wrote:
    > Subject: Re: what is the difference between getch() & getche()


    Neither are in the standard.

    [OT]getche() echoes, getch() does not.[/OT]
     
    Jordan Abel, Mar 5, 2006
    #11
  12. srikanth

    Randy Howard Guest

    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.

    --
    Randy Howard (2reply remove FOOBAR)
    "The power of accurate observation is called cynicism by those
    who have not got it." - George Bernard Shaw
     
    Randy Howard, Mar 5, 2006
    #12
  13. srikanth

    Randy Howard Guest

    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.




    --
    Randy Howard (2reply remove FOOBAR)
    "The power of accurate observation is called cynicism by those
    who have not got it." - George Bernard Shaw
     
    Randy Howard, Mar 5, 2006
    #13
  14. srikanth

    Randy Howard Guest

    B. P. TBC wrote
    (in article <>):

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


    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.



    --
    Randy Howard (2reply remove FOOBAR)
    "The power of accurate observation is called cynicism by those
    who have not got it." - George Bernard Shaw
     
    Randy Howard, Mar 5, 2006
    #14
  15. B. P. TBC wrote:
    > 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.


    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>
     
    Martin Ambuhl, Mar 5, 2006
    #15
  16. On Sun, 5 Mar 2006 20:05:43 +0000 (UTC), in comp.lang.c ,
    -cnrc.gc.ca (Walter Roberson) wrote:

    >In article <>,
    >srikanth <> wrote:
    >>help me out with the subject

    >
    >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
    --
    "Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are,
    by definition, not smart enough to debug it."
    --Brian Kernighan

    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    Mark McIntyre, Mar 5, 2006
    #16
  17. srikanth

    CBFalconer Guest

    "B. P. TBC" wrote:
    > 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.


    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/>
     
    CBFalconer, Mar 5, 2006
    #17
  18. "srikanth" <> wrote in message
    news:...
    > 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
     
    Rod Pemberton, Mar 6, 2006
    #18
  19. "srikanth" <> writes:
    > 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>


    1. You are mistaken.

    2. Read <http://cfaj.freeshell.org/google/>.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Mar 6, 2006
    #19
  20. srikanth

    Al Balmer Guest

    On Sun, 05 Mar 2006 22:52:39 +0000, Mark McIntyre
    <> wrote:

    >>I've never heard of getche(). Did you perhaps mean getchar() ?

    >
    >Its some ancient borland extension to C.


    <OT> It predates Borland, and is "etch() with echo."

    Now, you may ask, what is etch()? It's off-topic.
    </OT>

    --
    Al Balmer
    Sun City, AZ
     
    Al Balmer, Mar 6, 2006
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. srikanth
    Replies:
    0
    Views:
    335
    srikanth
    Mar 5, 2006
  2. James McLaughlin

    getch() and getche()

    James McLaughlin, Apr 3, 2006, in forum: C Programming
    Replies:
    9
    Views:
    810
    Kenneth Brody
    May 3, 2006
  3. diff bet getch() & getche()

    , Aug 8, 2006, in forum: C Programming
    Replies:
    6
    Views:
    516
    Barry Schwarz
    Aug 10, 2006
  4. Replies:
    4
    Views:
    467
    Rolf Magnus
    May 2, 2006
  5. aman
    Replies:
    5
    Views:
    814
    Bill Pursell
    Apr 11, 2007
Loading...

Share This Page