日期:2014-05-17 浏览次数:21735 次
password.exe
FOR /F %%p IN (password.txt) DO set PASSWORD=%%p
del password.txt >nul
if "%PASSWORD%"=="" goto e
if "%PASSWORD%"=="" goto e
rem 做需要%PASSWORD%的一系列工作
:e
set PASSWORD=
#include <conio.h>
#include <stdio.h>
char pw[40];
int i,ch;
FILE *f;
void main() {
cprintf("\r\nPassword:");
i=0;pw[i]=0;
while (1) {
ch=getch();
if (ch==13
------解决方案--------------------
i>=39) break;
switch (ch) {
case 27:
cprintf("\rPassword: %40s"," ");
cprintf("\rPassword: ");
i=0;pw[i]=0;
break;
case 8:
if (i>0) {
i--;
pw[i]=0;
cprintf("\b \b");
}
break;
default:
pw[i]=ch;
i++;
pw[i]=0;
cprintf("*");
break;
}
}
cprintf("\r\n");
f=fopen("password.txt","w");
fprintf(f,"%s\n",pw);
fclose(f);
}