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");
本文介绍了在DOS窗口中编程的一些实用技巧,包括如何使用getch()获取输入但不显示字符,实现密码输入时的星号显示效果;如何让程序暂停指定秒数;以及如何清空DOS窗口。
2530

被折叠的 条评论
为什么被折叠?



