Read and write user input, screen does not echo
Char *getpass (const char *prompt);
The getpass is used to read user input from the keyboard, but the screen does not echo.
The parameter prompt is the screen prompt character.
The function returns a string that is entered by the user's keyboard.
The screen does not indicate that the user entered the content, does not display any prompt message, that is, when switching users in Linux, the input password is not realistic.
The procedure is as follows:
1#include <stdio.h>2#include <unistd.h>3 4 intMainintargcChar*args[])5 { 6 //Call the Getpass function7 //parameter of function is prompt information8 //The return value of the function is what the user entered9 Char*password = Getpass ("Input your password:"); Ten //output User-entered information Oneprintf"Password =%s\n", password); A return 0; - } - the
To compile and execute the program :
- [Email protected] mycode]$ Gcc-o main MAIN.C
- [Email protected] mycode]$./main
- Input your password:------------here will not echo
- Password = 123456
C program Implementation password secret input Linux system executable