[LUAU] reading password.

Chris Wong wongc at math.ed.hawaii.edu
Thu May 20 16:02:02 PDT 1999


On Thu, 20 May 1999, David & Max wrote:

> I have a question about programming in C under Linux.  I'm writing a little
> database program that requires a user to login.  But I just don't know what
> C function I can use to read a user's password without displaying it on the
> screen? (just like the UNIX login process).  I know that under
> turbo/Borland C, there is a function called getch() that can do the job,
> but what about in gcc?  I don't want to use curses library or something
> like that for now.  Is there any standard C function that can do the job?

Quickest? if you're not worried about security... system("stty -noecho")
and system("stty echo");

Single character I/O is rather dificult. Your best bet is using curses. 

Check out man ncurses

noecho()
echo()
cbreak()
nocbreak()

and finally.. getch()

That should work. If you need sample code let me know.

Otherwise just turning echo off on a system should work.


--
chris


--
-     __   __  __________  __
-    / /  / / / / __  / / / /  Home Page: http://luau.hi.net
-   / /__/ /_/ / /_/ / /_/ /
-  /____/\____/_/ /_/\____/  LUAU - Linux Users AnonymoUs - Hawaii

-   To unsubscribe: echo unsubscribe luau | mail majordomo at luau.hi.net
-           LUAU meetings are the 3rd Tuesday of each month 6pm
-                   Manoa Innovation Center Meeting Room



More information about the LUAU mailing list