#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int x = 0;
char c;
char Password[6];
printf("请输入密码\n\n");
while(x < 5 && c != 13) //13是回车符的ASCII码
{
c = getchar();
Password[x++] = c;
if(c != 13)
putchar('*');
}
Password[x] = '\0';
printf("\n%s\n",Password);
return 0;
}
结果截图: