[try Beta version]
Not logged in

 
Alternative to conio.h?

Oct 2, 2008 at 11:34am
Does anyone kow a getch() function for linux not in conio.h?
Or any alternative? Please!
Oct 2, 2008 at 2:19pm
Use NCurses.

sudo apt-get install ncurses-dev

(or whatever your equivalent) to make sure you have everything for development with the NCurses library (including the ncurses shared library and terminfo database runtime stuff)

See also here
http://www.cplusplus.com/forum/beginner/4520/page1.html#msg19965

Hope this helps.
Oct 2, 2008 at 3:28pm
BIG BIG Thanks!
I tried to use ncurses before but i never thought about functions required to use it.
Oct 3, 2008 at 3:13pm
Oops...
I didn't tried the code and there something wrong:
when i try to use getch i get an error: invalid conversion from int(*)() to char.
I tried to change char to int and long but alway i get error and i have no idea what to do.
Oct 3, 2008 at 8:55pm
Er, I goofed twice on that example. It is fixed now.

Unfortunately, the curses library was written with a lot of its functions prototyped to take char*, when they should really take const char*, so you have to cast to keep the compiler happy when sending in string literals. (That, or tell your compiler to make string literals writeable, which I don't recommend.)

What line is complaining about the "int(*)() to char"?
Oct 4, 2008 at 9:23am
You most likely have something like
int x = getch;
when it should be
int x = getch();
Oct 4, 2008 at 11:07pm
Nice catch! I forgot about that! :-)
Topic archived. No new replies allowed.