LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   getchar() 's odd behavior (https://www.linuxquestions.org/questions/linux-newbie-8/getchar-s-odd-behavior-39044/)

jenna_h 12-21-2002 10:46 AM

getchar() 's odd behavior
 
I don't know if this is the right forum to post in, but this is probably a simple question. I've just started writing C programs, using the gcc compiler. However, my manual refers to a function called "getche()" that receives input from the keyboard without printing it on the screen and forcing you to press enter. It says this is a non-standard function, and you have to include the file "conio.h" to use it. I assume gcc doesn't have that file. All I really want to do is use non-line-buffered input in my program. Is there a way to do that? Better yet, is there a place where I could read about the functions included with gcc and get to know them better?

yadavankur 12-21-2002 12:33 PM

curses.h to the rescue.
curses.h is good for console based apps made in c.
personally I CURSE IT %$@#^@.

Try the gcc website gcc.gnu.org/
or
gcc.gnu.org/onlinedocs/ <-better
or
try $info gcc.
(I am not sure about contents of any of these)

16977 12-21-2002 02:50 PM

Thanks! The Curses library was right in my /include directory, and the website you mentioned has a lot of info on using it.

yadavankur 12-22-2002 12:29 PM

It striked me all of sudden that I made a mistake when I told you to use curses.h

Its like using a gun to shoot a bee.
curses.h is 'a bit' high on the learning curve and is not ment to be an addition to a console based program.

It is a different approch.With curses.h U do not write a program and include curses.h into your program. Instead U write a curses based program and then add the functionality that U wanted. Its not to be used unless U want a user freindly console like GUI program. Curse does add a lot of power to Ur console app like mouse clicks(even triple clicks and scrolling) but in Ur case curses wont replace getche().First U replace the entire code to make it curse freindly and then add Ur orignal code. I recomend U look elswhere.

Besides people do not make console based apps anymore. For the time one devotes to learning curses he is better of utilizing it to learn Qt instead and make some KDE based apps.


All times are GMT -5. The time now is 09:57 AM.