1。在dos窗口中顯星號
#include "stdio.h"
int main(int argc, char* argv[])
{
char password[20],c;
int i = 0;
while(1)
{
c = getch();
if(c == 13)
break;
password[i++] = c;
printf("*");
}
password[i] = '/0';
printf("/nThe input password is %s/n",password); getch();
return 0;
}
2。c++中的getch()在"conio.h"頭文件中
3。若要讓程序暫停若干秒,需要用Sleep()。調用該函數需要#include"windows.h"
如Sleep(1000); //暫停1秒
4。dos窗口清屏用system("cls");