Damn no "getch()"

This is a discussion on Damn no "getch()" within the C Programming forums, part of the General Programming Boards category; I use Linux, so I don't have the header <conio.h>, this means i cannot use "getch()" in my programs, does ...

  1. #1
    Me-Again
    Guest

    Angry Damn no "getch()"

    I use Linux, so I don't have the header <conio.h>, this means i cannot use "getch()" in my programs, does anyone know how this is written, or could lead me in some direction? All help will be appreciated.

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    This is an easy one. Go to the FAQ for this site.

  3. #3
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    Posts
    742
    You could probably substitute getchar() instead of _getch();

    int ch = getchar();
    I compile code with:
    Visual Studio.NET beta2

  4. #4
    Me-Again
    Guest

    Question Clarifying a point

    I assume you were referring to "X-header" in the FAQ. I would like to clarify something. I don't want the header file or the library. I would like some direction on how "getch()" works, I don't expect someone to write the program for (they can if they have nothing to do though) but I'm still learning so I would prefer direction and when I get stuck then ask for help from someone who already knows how to do it. I'm sorry for not clarifying it earlier.

  5. #5
    Unregistered
    Guest

    =

    I typed the one above while the other was sent.

    "ch = getchar();"

  6. #6
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    getchar() is by no means an equivilent to the getch()(the common version that is)... their for different purposes all together... Why do people keep stating otherwise...

  7. #7
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    Posts
    742
    getchar() is by no means an equivilent to the getch()(the common version that is)... their for different purposes all together... Why do people keep stating otherwise...
    Boo Hoo, Whah! In terms of pausing the screen if you do not have _getch() than you can use getchar() instead. Nobody said that they are the same. Infact this guy should get VS.NET and never worry again!

    Prototype information
    int _getch( void );

    Return Value
    Returns the character read. There is no error return.

    Remarks
    The _getch and _getwch functions read a single character from the console without echoing. _getche and _getwche read a single character from the console and echo the character read. None of these functions can be used to read CTRL+C. When reading a function key or an arrow key, each function must be called twice; the first call returns 0 or 0xE0, and the second call returns the actual key code.
    I compile code with:
    Visual Studio.NET beta2

  8. #8
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    In other words: The innerworkings of get***** functions are simply beyond the scope of this book!

    No, seriously, though, is _getch the linux version?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  9. #9
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    Posts
    742
    No, seriously, though, is _getch the linux version?
    _getch() is the Microsoft version.
    I compile code with:
    Visual Studio.NET beta2

  10. #10
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Ohhh... gotchya,...(on _getch)...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  11. #11
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Me-Again, I was referring to question 2 on the FAQ.

  12. #12
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    If you are writing a game and would be using getch for input I recommend using
    the SDL's input functions. Other whys I guess just use ncurses.

  13. #13
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    You will want to download ncurses anyways. You must have the runtime of
    the library you just need to download the developement version.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Damn ATI!
    By AloneInTheDark in forum Tech Board
    Replies: 48
    Last Post: 02-16-2008, 09:34 PM
  2. linked list and damn on linked list
    By St0rM-MaN in forum C Programming
    Replies: 13
    Last Post: 07-03-2007, 05:08 PM
  3. What makes WoW so damn addictive?
    By cboard_member in forum A Brief History of Cprogramming.com
    Replies: 91
    Last Post: 06-29-2006, 12:38 AM
  4. Damn!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 12-04-2001, 11:32 PM
  5. Damn Management!
    By Govtcheez in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 09-06-2001, 05:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21