① c語言中,用什麼函數可以使輸入的字元不顯示在屏幕上
getpass()函數可以使輸入的字元不現實在屏幕上。
#include
<conio.h>
int
main(void)
{
char
*password;
password
=
getpass("Input
a
password:");
cprintf("The
password
is:
%s\r\n",
password);
return
0;
}
你試一試這個
② linux系統下用C語言編了個下程序,不知道如何在輸入密碼時隱藏,只顯示「*」,求大神們幫幫忙啊 !!!
函數名: getch
功 能: 從控制台無回顯地取一個字元
用 法: int getch(void);
#include<conio.h>
#include<stdio.h>
intmain(void)
{
charp[50];
inti=-1;
do{
++i;
p[i]=getch();
putchar('*');
}while(p[i]!=13);//13為回車ascii
p[i+1]='