ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how to get characters without echoing on the standard output.
In windows we have getch() to do this ,but it is not working
in linux. I tried with all types of getch statements then
also it is not coming.
I'm just starting to play with curses, and have found noecho() to do precisely that.
Then again, as I have just started playing, I am not fully aware of the purpose of everything I'm doing. (But I'm pretty sure about this, as it was in the man page.)
The ncurses library has a getch() function. However, getch() is just used to pass input to the program. noecho() initializes the program to not echo the input. The basic guide and some examples can be found here.
If you would like another example, I wrote a pong-style game using ncurses while I was learning C++.
Disclaimer- The actual gameplay code isn't all that spectacular and is not that efficient, but it should provide a decent example of how ncurses can be used
I used to be caught up in this as well. ncurses actually implements getch() very similarly to the windows counterpart. The only thing is, you have to execute several other functions to make it work right such as noecho(), raw() and other functions (I haven't used ncurses in over 2 years, so I'm getting rusty). Also, if you want to do complicated keyboard manipulation, just look out for escape sequences (I'm not sure if windows did it this way -- haven't programmed in windows even longer).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.