encrypt.c

来自「这是一些c++例程」· C语言 代码 · 共 76 行

C
76
字号
#include <stdio.h>
#include <string.h>

void main() 
{ 
	char *password; 
	char kl[9]; 
	int i=0; 
	FILE *fp;
	 
	fp=fopen("KLK.CFG","rb+");
	if(fp!=NULL) 
	{ 
		fseek(fp,0,SEEK_SET); 
		fgets(kl,9,fp); 
		fclose(fp); 
	}
	else
	{
		gotoxy(13,2);
		cputs("No need password!!!");
		getch();
		exit(0);
	}
	
	/* 屏幕背景清屏成蓝色 */ 
	window(1,1,80,25);
	textbackground(1); 
	clrscr(); 
	
	/* 开阴影窗口 */
	window(17,10,58,13);
	textbackground(0); 
	clrscr();
		
	for(i=0;i<=2;i++) 
	{ 
		window(16,9,56,12); 
		textattr(14 | 2<<4); 
		clrscr();
		 
		gotoxy(13,2); 
		password=(char *)getpass("Please input password:"); 
		
		textcolor(4);
		
		if(strcmp(password,kl)!=0)
		{
			gotoxy(13,2); 
			cputs("password error,");
			if(i == 2)	/* 三次口令无效退出 */ 
			{
				cputs("exit!!!"); 
				getch(); 
				exit(0); 
			}
			else		/* 前两次错误,提示重新输入 */
			{
				cputs("Please input again!!!");
				getch();
			}
		} 
		else
			break;
	}
	 
	/* 进入主程序体 */ 
	textbackground(1); 
	window(1,1,80,25); 
	clrscr(); 
	
	gotoxy(10,10); 
	cputs("pass!!!"); 
	getch();
} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?