Results 1 to 6 of 6

Thread: Is getch() function there in c library?

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore,India
    Beans
    982
    Distro
    Ubuntu 10.04 Lucid Lynx

    Smile Is getch() function there in c library?

    i tried most of programs using getch() function and i also added <stdlib> library but compiler throws an error,saying getch() is not defined,how to use getch() function?
    Abhilash Muthuraj-views
    I always believe that Linux,
    "In a world of no walls or fences, we don't need WINDOWS or GATES"
    New to Ubuntu??

  2. #2
    Join Date
    Jul 2008
    Location
    Aryadesa
    Beans
    183
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Is getch() function there in c library?

    getch() is not present in glibc. In turboc, it is declared in conio.h, which is not present in glibc. Alternatively you can use getchar().
    Quantum computers are not known to be able to solve NP-complete problems in polynomial time.
    Scott Aaronson's blog

  3. #3
    Join Date
    Dec 2008
    Location
    Littleton, Colorado USA
    Beans
    362
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: Is getch() function there in c library?

    Build your own getc using getc or getchar in a macro.

    #define getch getc

    Years ago we built a getch.c as a Ratfor primative and it looked like->

    /* Get next input character from stream */

    #include <stdio.h>
    #include "ratdef.h"
    #include "ofiles.h"

    char getch( char *c, filedes fd )
    {
    *c = (char) getc( fbuf[fd] );
    return( *c );
    }

  4. #4
    Join Date
    Jul 2008
    Location
    Newton City, Terminus
    Beans
    60
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Is getch() function there in c library?

    I'm tired of this getch() question. lensman3, kcode and many others have given many alternatives for getch(). The other is using ncurses. Abhilashman you should look at the solutions in the other threads that you had started. How many times have I told you not to use getch(). This function are no longer used. Adapt plz.

  5. #5
    Join Date
    Nov 2008
    Beans
    39

    Re: Is getch() function there in c library?

    we would adapt, but a good alternative has not been presented. New programmers to linux were not taught crossplatform programming. You need to give a simple, explanation mabey with some examples, on how the same task is accomplished in linux then all you have to do is refrence that explanation. We can't find one. All the threads just say, "get rid of conio.h, clrscr, getch, and kbhit. But that doesn't allow the program to run. getch() is used for a lot more then just a pause at the end of the program and clrscr is used for a heck of a lot more then just starting the program. The other explanation is to use another library that is present in linux but nobody gives an explanation as to how. okay, so do I have to work my function in a completely new way or is there just an alternative function to call to do the exact same thing? Also, a lot of windows programmers don't understand scripts, how to write them, or how to use them. Where can we get started? Saying "Make a script" to a windows user means nothing. This is why a lot of people mess with linux for a short period of time and then go back to windows. If somebody is trying to use conio.h or some other windows header, they obviously don't understand the intracacies of linux and need a barny style lesson. If one exists, where can they find it? I wish somebody would create a wiki on windows to linux programming for beginners. Then you could just reference that whenever somebody asks what you concider to be a, "stupid" question. It's not a lack of adapting, its a lack of ignorance. Ignorance can be overcome, defiance can't.

  6. #6
    Join Date
    Nov 2011
    Beans
    2

    Re: Is getch() function there in c library?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •