注:
本学生管理系统基于Visual Studio 2022版本书写且采用函数嵌套使用。以下C语言代码,均缺少头文件以及函数调用模块代码,仅供学习者,参考书写,如需完整代码,可查看博主主页资源分享!!!!
void Welcome();//欢迎界面
采用延迟,循环和色彩,做出动态加载效果。
void Welcome()
{
int i;
system("cls");//清屏闪烁
for (i = 0; i <= 100; i = i + 10)
{
system("cls");
printf("\n\n\n\n\t\t\t\t************\n");
printf("\t\t\t\t Welcome!\n");
printf("\t\t\t\t************\n");
printf("\n\t\t\t\t %d%\n\n\n", i);
Sleep(60);
}
system("Color a");
Sleep(200);
system("Color b");
Sleep(200);
system("Color c");
Sleep(200);
system("Color d");
Sleep(200);
system("Color e");
Sleep(200);
system("Color f");
Sleep(200);
system("Color 3e");
}
void Lo_si();//注册登录界面
通过switch语言,来实现选择性进入。
//注册登录界面
void Lo_si()
{
int choose, ch;
system("color 3e");
while (1) {
system("cls");
printf("\t\t\t--------------------------------------\n");
printf("\t\t\t| 登 录 选 择 系 统 |\n");
printf("\t\t\t--------------------------------------\n");
printf("\t\t\t菜单:\n\t\t\t1.注册账户\n\t\t\t2.登录\n\t\t\t0.结束\n");
printf("\t\t\t--------------------------------------\n");
printf("\t\t\t请输入您的选择(1,2,0?):\n");
printf("\t\t\t");
scanf("%d", &choose);
switch (choose) {
case 1:
Sign();
break;
case 2:
Login();
break;
case 0:
Thanks();
exit(0);
default:
printf("输入错误!是否重新输入【Y\\y or N\\n】\n");
printf("\n\t\t\tchoose:");
getchar();
ch = getchar();
if (ch == 'Y' || ch == 'y')
continue;
else
return;
}
}
}
void Sign();//注册系统
采用文件储存账号信息,以满足多账户,选择性登录,同时采用if—else语言,实现判断登录。
//注册系统
void Sign()
{
FILE* fp;
User user;
int num = 1;
char ch;
char repassword[20];
do {
system("cls");
printf("\t\t\t-----------------------------------\n");
printf("\t\t\t| 账户 注 册 系 统 |\n");
printf("\t\t\t-----------------------------------\n");
printf("\t\t\t请输入用户名:");
scanf("%s", user.username);
printf("\n\t\t\t请输入密码:");
scanf("%s", user.password);
if ((fp = fopen("users.txt", "a")) == NULL) {
printf("\n\n\t\t\tusers.txt 打开失败!\n");
exit(0);
}
printf("\n\n\t\t\t确认密码:");
scanf("%s", repassword);
if (strcmp(user.password, repassword) != 0)//比较字符串是否一样
{
printf("\n\t\t密码输入不一致!\t是否重新输入?【Y\\y or N\\n】");
printf("\n\t\t\tchoose:");
printf("\t\t\t");
getchar();
ch = getchar();//将getchar的读取的字符储存在ch中
if (ch == 'Y' || ch == 'y')
continue;
else
return;
}
fprintf(fp, "%s %s\n", user.username, user.password);
fclose(fp);
printf("\n\n\t\t\t注册成功!\n");
system("pause");
num = 1;
} while (num != 1);
}