Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-04-2007, 06:22 AM   #16
Registered: Sep 2006
Distribution: Fedora Core 10
Posts: 254

Original Poster
Rep: Reputation: 32

oh... but will any of the funcitons tcgetattr() tcsetattr() can echo a charecter on the screen by taking the input from the standard input device (keyboard)?? and what makes those functions getch() nocbreak() echo() worse ???
Old 01-04-2007, 08:37 AM   #17
Senior Member
Registered: Jul 2005
Distribution: Slackware
Posts: 2,014

Rep: Reputation: 115Reputation: 115
He's saying don't use curses if you don't really need curses (with a little subtle warning about the kind of headaches you get with curses, I can't vouch for that part). Instead, put the terminal into raw mode like
   struct termios cur,raw;
and restore by doing
See the respective man pages to figure out how it works.

Last edited by tuxdev; 01-04-2007 at 08:48 AM.
Old 01-04-2007, 10:13 AM   #18
LQ Newbie
Registered: May 2006
Location: Sweden
Distribution: Vector Linux
Posts: 28

Rep: Reputation: 15
What's wrong with using curses?
Old 01-04-2007, 10:22 PM   #19
Registered: Sep 2006
Distribution: Fedora Core 10
Posts: 254

Original Poster
Rep: Reputation: 32
thanks tuxdev.....
but my question is as we do in VC++ to echo a charecter...........say char ch; ch=getch(); this will echo the charecter typed by the user and,can same thing work in linux...???? if no what to do to echo a charecter on the screen here ?? and the prototypes as in man pages for getch() cbreak() raw() and echo() simply accept nothing and returns int... how to use those in the there something else to be done...please gimme a simple code to echo a charecter on the screen...
Old 04-07-2007, 11:02 PM   #20
Registered: Oct 2003
Location: Ohio , USA
Distribution: up to Suse 13.1
Posts: 71

Rep: Reputation: 25
getch in linux

I am working at programming in Linux as well. I am used to the getch() command in windows and the getche() [which does the echo] that gets one character from the keyboard and continues right on.

What you rarely get is a real answer. It is a waste of time getting replies like that.

This site:

is the 1st I have been able to find that comes close at all.
It uses getchar() command BUT you must hit return to continue.

Also :

lists the info on "one-character-at-a-time mode (getch() in DOS)". It seems good to have the device active like this and not waiting for the user forever but who would know to look for this?

I am looking to write a simple texted based game and I really do not want to press enter after every key.

I am looking further myself but if you find or have found anything, please let me know.


Last edited by Kumado; 04-07-2007 at 11:15 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is getch()....... rajsun Programming 2 03-28-2005 11:40 AM
getch function prasad514 Programming 6 01-03-2005 11:48 AM
Help with getch... darkarcon2015 Programming 4 09-12-2004 08:48 AM
how to get getch() working with c++ cool_ashwin22 Programming 3 08-03-2004 10:58 AM
ncurses getch() deveraux83 Programming 3 08-06-2003 07:27 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:39 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration