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.
Printable View
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.
This is an easy one. Go to the FAQ for this site.
You could probably substitute getchar() instead of _getch();
int ch = getchar();
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.
I typed the one above while the other was sent.
"ch = getchar();"
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!Quote:
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...
Prototype information
Quote:
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.
In other words: The innerworkings of get***** functions are simply beyond the scope of this book!
No, seriously, though, is _getch the linux version?
_getch() is the Microsoft version.Quote:
No, seriously, though, is _getch the linux version?
:eek: Ohhh... gotchya,...(on _getch)...:D
Me-Again, I was referring to question 2 on the FAQ.
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.
You will want to download ncurses anyways. You must have the runtime of
the library you just need to download the developement version.