I want to allow users to enter password using command-line interface. but I don't want to display this password on screen (or display "****").
How to do it in C? Thanks.
Update:
I'm working on Linux only. So I don't actually care about Win or other systems. I tried Lucas' solution and it worked fine. However, I still have another question:
If this is a single process & single thread app, changing setting of termios affects different terminals?
How about 1 process - multi threads, multi processes - multi threads?
Thanks very much.
If you have access to the curses library, you can use noecho. If you're using Microsoft's C compiler, you can use _getch. But afaik, both of these tie you to the console. If you need to read stdin regardless of whether it comes from the console or a file or a piped command, you need to tell the operating system how it should handle the console.