#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define MAX_SIZE 20
//学生信息结构体
struct stu_information//这里使用了struct结构体
{
char Name[MAX_SIZE];
int Gender;
int Sno;
char ID[MAX_SIZE];
char telephone[MAX_SIZE];
char mailbox[MAX_SIZE];
char Cipher[MAX_SIZE];
}*s;
int num=0;
void EnterPassWard(char *passward);为什么是void
void logon();//这个是什么函数,有什么作用
int main()//这个主函数是在干什么
{
int flag=1;
char Flag,ch;
s=(struct stu_information )malloc(100sizeof(struct stu_information));
char UserName[MAX_SIZE];
char Cipher[MAX_SIZE];
while(1)这个是while选择语句嘛,他在干什么
{
system("cls");//清空有什么作用
printf("请选择一项服务:\n1.登录已有账号\n2.注册新用户\n");
flag=getch();
if(flag==49)
{ system("cls");
printf("输入用户名:");
scanf("%s",UserName);
L1: printf("密码:");
EnterPassWard(Cipher);
flag=CheckIfExist(UserName,Cipher,s);
if(flag==0)
{
printf("密码错误!\n");
goto L1;
}
else if(flag==-1)
{
printf("\n用户不存在!\n");
printf("是否注册新用户?(Y/N)");
getchar();
scanf("%c",&Flag);
if(Flag=='Y'|| Flag=='y')
logon();
}
注释如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define MAX_SIZE 20
//学生信息结构体
struct stu_information//这里定义了struct结构体
{
char Name[MAX_SIZE];
int Gender;
int Sno;
char ID[MAX_SIZE];
char telephone[MAX_SIZE];
char mailbox[MAX_SIZE];
char Cipher[MAX_SIZE];
}*s;
int num = 0;
void EnterPassWard(char* passward); // void:表示这个函数无返回值
void logon();//这里只是函数声明,函数作用由你写的函数决定
int main()//main函数是程序入口,运行程序后从main函数开始运行
{
int flag = 1;
char Flag, ch;
s = (struct stu_information)malloc(100sizeof(struct stu_information));
char UserName[MAX_SIZE];
char Cipher[MAX_SIZE];
while (1) //这个是while循环语句,while(1)保证代码一直处于循环当中,不会退出
{
system("cls");//清空屏幕,看着舒适
printf("请选择一项服务:\n1.登录已有账号\n2.注册新用户\n");
flag = getch();
if (flag == 49)
{
system("cls");
printf("输入用户名:");
scanf("%s",UserName);
L1: printf("密码:");
EnterPassWard(Cipher);
flag = CheckIfExist(UserName,Cipher,s);
if (flag == 0)
{
printf("密码错误!\n");
goto L1;
}
else if (flag == -1)
{
printf("\n用户不存在!\n");
printf("是否注册新用户?(Y/N)");
getchar();
scanf("%c",&Flag);
if (Flag == 'Y' || Flag == 'y')
logon();
}
你代码没发全吧,上面声明的函数都没有函数体