Source Code File 08-08_urpwd
08-08_urpwd.c
#include <ncurses.h> int main() { char name[32]; char password[32]; initscr(); addstr("Name: "); getnstr(name,32); /* disable text output */ noecho(); addstr("Password: "); getnstr(password,31); /* enable text output */ echo(); printw("%s's password is '%s'\n", name, password); refresh(); getch(); endwin(); return(0); }
Output Screenshot
Notes
* Displaying a password after you type it in without echo is, of course, dumb.
* More difficult is to write a routine that displays asterisks instead of characters input. Creating such a function is possible in Ncurses, and I leave it up to you to concoct such a thing.
Copyright © 1997-2024 by QPBC.
All rights reserved