Implementation of Student Information Management System in C Language (File version)

  • 2020-10-31 21:57:00
  • OfStack

The example of this paper shares the specific code of C language to implement the student information management system for your reference. The specific content is as follows

The following is the student information management system written by myself. In order to increase the utilization rate of data, it is divided into the student side and the teacher side. Meanwhile, it realizes the login of account and password and saves it in the form of files.

The following code


#include <stdio.h>
#include <string.h> 
#include <string>
#include<Windows.h>
#define USER "TOM"  //  Define a username in advance for the login page and authentication.  
#define PW "123456789" //  Predefine password   Same as above. 
void Level_menu();// Declaration of the main menu -- Choose student or teacher. 
void Level_2_menu(); //2 Level menu - specific function differentiation  
void Student_add_Level_3_menu();//  Add student information menu function differentiation  
void Student_Insert(); // Add individual student information  
void Student_Insert1(); /* The function set for the above batch input has the same code as the above 
          Single input similar, truncated 1 Part of the */

void Student_Tongji_menu();// Statistical Menu section 
void Student_Tongji_menu2();// statistical 2 menu  
void Student_Tongji_menu3();// statistical  
void IO_ReadInfo();/* Transfer student information from the file ( student database.txt ) read */ 
void IO_WriteInfo();/* Write student information to a file ( Database.txt ) */ 
void student_Delete_menu(); /* Delete the student information menu */
void student_menu1();/* Students check the course information menu */
void student_Kecheng_menu2();
void Student_From_high_to_low1(); /* Rank the overall assessment from high to low */ 
void jiangxue_menu();/* Evaluation Method of Scholarship */ 
void Student_Display2();/* Display student information 2 Used in scholarship evaluation */


 
 
/* Define the student structure */ 
struct Student 
{
  char ID[20];  // Student id 
  char Name[20];  // The name  
  char sushe[6];  // Dormitory Room Number  
 float mathA1;  // Advanced Mathematics  
 float EnglishA1; // College English Score  
 float software;  // Introduction to Software Technology 
 float china_history;// Outline of Modern Chinese history 
 float junshi;  // Military education 
 float xinli;  // Mental Health counseling 
 float sports;  // sports */ 
  float C_Mark;  //C Language program design score 
  float pingjun;  // Total credit 
 float Banzhuren; // Head teacher grade 
 float Cepingfen; // The measurement points  
};

/* Declares the array of students and the number of students */ 
struct Student students[1000]; 
int num=0;
int Num; 

/* Returns the index of the array by the student number */ 
int Student_SearchByIndex(char id[]) 
{
 int i; 
 for (i=0;i<num;i++) 
 {
  if (strcmp(students[i].ID,id)==0) 
  {
   return i; 
  } 
 } 
 return -1; 
}

/* Returns the array index by name */
int Student_SearchByName(char name[]) 
{
 int i; 
 for (i=0;i<num;i++) 
 { 
  if (strcmp(students[i].Name,name)==0)
  { 
   return i;
  } 
 } 
 return -1; 
} 

/* Returns array index via dormitory member */
void Student_SearchBySushe()

{
 system("cls");
 system("color f0");
 int i;
 char Sushe[6] ;
 printf(" Please enter the dorm room number you want to check:  ");
 scanf("%s",&Sushe); 
 printf("%10s%10s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n"," Student id "," The name "," The dormitory no. "," Higher mathematics "," The university English "," Introduction to Software Technology "," Modern Chinese history "," Military education "," Mental health education "," College sports ","C Language performance "," Total credit "," Head teacher grade "," The measurement points "); 
 printf("------------------------------------------------------------------------------------------------------------------------\n"); 
 
 
  
 for (i=0;i<num;i++) 
 { 
  if (strcmp(students[i].sushe,Sushe)==0)
  { 
   printf("%10s%10s%5s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[i].ID,students[i].Name,students[i].sushe,students[i].mathA1,students[i].EnglishA1,students[i].software,students[i].china_history,students[i].junshi,students[i].xinli,students[i].sports,students[i].C_Mark,students[i].pingjun,students[i].Banzhuren,students[i].Cepingfen); 
  }
  
 } 
 
 printf(" Data loaded! "); 
 Student_Tongji_menu2();
 
} 

/* Displays a single student record */ 
void Student_DisplaySingle(int index) 
{
 printf("%10s%10s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n"," Student id "," The name "," The dormitory no. "," Higher mathematics "," The university English "," Introduction to Software Technology "," Modern Chinese history "," Military education "," Mental health education "," College sports ","C Language performance "," conduct "); 
 printf("------------------------------------------------------------------------------------------------------------------------\n"); 
 printf("%10s%10s%5s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[index].ID,students[index].Name,students[index].sushe,students[index].mathA1,students[index].EnglishA1,students[index].software,students[index].china_history,students[index].junshi,students[index].xinli,students[index].sports,students[index].C_Mark,students[index].pingjun); 
} 

/* Add a single student record */ 
void Student_Insert() 
{ 
 system("cls");
 system("color f0");
 float a1,a2,a3,a4,a5,a6,a7,a8;
 float j=0; 
 while(1) 
 { 
  printf(" Please enter your student number :");
  scanf("%s",&students[num].ID); 
  getchar();
  printf(" Please enter your name :"); 
  scanf("%s",&students[num].Name); 
  getchar();
 printf(" Please enter the dormitory number :"); 
  scanf("%s",&students[num].sushe); 
  getchar();
 printf(" Please enter your advanced math score :"); 
  scanf("%f",&students[num].mathA1); 
  getchar();
  if (59<students[num].mathA1 && students[num].mathA1<100) 
  
   a8= 1.5;  
  
  else
  
   a8=0;
 

 printf(" Please enter your college English score :"); 
  scanf("%f",&students[num].EnglishA1); 
  getchar();
  if (59<students[num].EnglishA1 && students[num].EnglishA1<100) 
  
   a1= 2;  
  
   else
  
   a1=0;
 

 printf(" Please enter the software technical introduction score :"); 
  scanf("%f",&students[num].software); 
  getchar();
  if (59<students[num].software && students[num].software<100) 
  
   a2= 1.5;  
  
   else
  
   a2=0;
 

 printf(" Please enter the results of the outline of Modern Chinese history :"); 
  scanf("%f",&students[num].china_history); 
  getchar();
  if (59<students[num].china_history && students[num].china_history<100) 
  
   a3= 2.5;  
  
   else
  
   a3=0;
 

 printf(" Please enter military education :"); 
  scanf("%f",&students[num].junshi); 
  getchar();
  if (59<students[num].junshi && students[num].junshi<100) 
  
   a4= 2;  
  
   else
  {
   a4=0;
 }

 printf(" Please enter your mental health education score :"); 
  scanf("%f",&students[num].xinli); 
  getchar();
  if (59<students[num].xinli && students[num].xinli<100) 
  
   a5= 1.5;  
  
   else
  
   a5=0;
 
 printf(" Please enter your sports scores :"); 
  scanf("%f",&students[num].sports); 
  getchar();
  if (59<students[num].sports && students[num].sports<100) 
  
   a6= 2;  
  
   else
  
   a6=0;
 

 printf(" Please enter the C Language performance :"); 
  scanf("%f",&students[num].C_Mark); 
  getchar();
  if (59<students[num].C_Mark && students[num].C_Mark<100) 
  
   a7= 3.5;  
  
   else
  
   a7=0;
 
  
  printf(" Please enter the grade given by the head teacher :"); 
  scanf("%f",&students[num].Banzhuren); 
  getchar();
  students[num].pingjun=a1+a2+a3+a4+a5+a6+a7+a8; // Total credit  
  
  j=(students[num].pingjun*0.4)+(students[num].Banzhuren*0.6);
  students[num].Cepingfen=j;
  num++;

  printf(" Whether or not to continue ?(Y/N) Press any key to continue or enter N:"); 
  if (getchar()=='N') 
  { 
   Num=num;
   break;
  } 
  } 
}  

 
 /* Add student records in batch */ 
void Student_many1()
{
 { 
  system("cls");
  system("color f0");
  int i,j;
  printf(" Please enter the number of people you will add:  ");
  scanf("%d",&j); 
 for(i=0;i<j;i++)
 {
 Student_Insert1();
 }
 printf(" After adding a member, whether jump first or not 1 Menu? \n");
 printf(" Is? , please press any key to confirm input : \n"); 
  if (getchar()=='Y') 
  { 
   Student_add_Level_3_menu(); 
  } 
  
 }
 } 
/* The function set for the above batch input has the same code as the above 
 Single input similar, truncated 1 Part of the */ 
void Student_Insert1() 
{ 
 
 {
  printf(" Please enter your student number :"); 
  scanf("%s",&students[num].ID); 
  getchar(); 
  printf(" Please enter your name :"); 
  scanf("%s",&students[num].Name); 
  getchar();
 printf(" Please enter the dormitory number :"); 
  scanf("%s",&students[num].sushe); 
  getchar();
 printf(" Please enter your advanced math score :"); 
  scanf("%f",&students[num].mathA1); 
  getchar();
 printf(" Please enter your college English score :"); 
  scanf("%f",&students[num].EnglishA1); 
  getchar();
 printf(" Please enter the software technical introduction score :"); 
  scanf("%f",&students[num].software); 
  getchar();
 printf(" Please enter the results of the outline of Modern Chinese history :"); 
  scanf("%f",&students[num].china_history); 
  getchar();
 printf(" Please enter military education :"); 
  scanf("%f",&students[num].junshi); 
  getchar();
 printf(" Please enter your mental health education score :"); 
  scanf("%f",&students[num].xinli); 
  getchar();
 printf(" Please enter your sports scores :"); 
  scanf("%f",&students[num].sports); 
  getchar();
 printf(" Please enter the C Language performance :"); 
  scanf("%f",&students[num].C_Mark); 
  getchar();
  printf(" Please enter the grade given by the head teacher :"); 
  scanf("%f",&students[num].Banzhuren); 
  getchar();
  if (54<students[num].C_Mark && students[num].C_Mark< 60) // the 55~59 All the points in between are added 5 points 
  {
   students[num].C_Mark += 5;  
  }

  num++;
  } 
} 
/* Modify student information */ 
void Student_Modify() 
{ 
 system("cls");
 system("color f0");
 float a1,a2,a3,a4,a5,a6,a7,a8;
 float j=0; 
 while(1) 
 { 
  char id[20]; 
  int index; 
  printf(" Please enter the student number you want to modify :"); 
  scanf("%s",&id); 
  getchar(); 
  index=Student_SearchByIndex(id); 
  if (index==-1) 
  { 
   printf(" The student does not exist !\n"); 
   }
  else 
  { 
   printf(" The student information you want to modify is :\n"); 
   Student_DisplaySingle(index); 
   printf("--  Please enter a new value --\n"); 
   /*printf(" Please enter your student number :"); 
   scanf("%s",&students[index].ID); 
   getchar(); 
   printf(" Please enter your name :"); 
   scanf("%s",&students[index].Name); 
   getchar(); 
 printf(" Please enter the dormitory number :"); 
   scanf("%s",&students[index].sushe); 
   getchar();
  printf(" Please enter your advanced math score :"); 
   scanf("%f",&students[index].mathA1); 
   getchar();
  printf(" Please enter your college English score :"); 
   scanf("%f",&students[index].EnglishA1); 
   getchar();
  printf(" Please enter the software technical introduction score :"); 
   scanf("%f",&students[index].software); 
   getchar();
  printf(" Please enter the results of the outline of Modern Chinese history :"); 
   scanf("%f",&students[index].china_history); 
   getchar();
  printf(" Please enter military education :"); 
   scanf("%f",&students[index].junshi); 
   getchar();
  printf(" Please enter your mental health education score :"); 
   scanf("%f",&students[index].xinli); 
   getchar();
  printf(" Please enter your sports scores :"); 
   scanf("%f",&students[index].sports); 
   getchar();
   printf(" Please enter the C Language performance :"); 
   scanf("%f",&students[index].C_Mark); 
   getchar();
 printf(" Please enter the grade given by the head teacher :"); 
   scanf("%f",&students[num].Banzhuren); 
   getchar();*/
 printf(" Please enter your student number :");
  scanf("%s",&students[index].ID); 
  getchar();
  printf(" Please enter your name :"); 
  scanf("%s",&students[index].Name); 
  getchar();
 printf(" Please enter the dormitory number :"); 
  scanf("%s",&students[index].sushe); 
  getchar();
 printf(" Please enter your advanced math score :"); 
  scanf("%f",&students[index].mathA1); 
  getchar();
  if (59<students[index].mathA1 && students[index].mathA1<100) 
  
   a8= 1.5;  
  
  else
  
   a8=0;
 

 printf(" Please enter your college English score :"); 
  scanf("%f",&students[index].EnglishA1); 
  getchar();
  if (59<students[index].EnglishA1 && students[index].EnglishA1<100) 
  
   a1= 2;  
  
   else
  
   a1=0;
 

 printf(" Please enter the software technical introduction score :"); 
  scanf("%f",&students[index].software); 
  getchar();
  if (59<students[index].software && students[index].software<100) 
  
   a2= 1.5;  
  
   else
  
   a2=0;
 

 printf(" Please enter the results of the outline of Modern Chinese history :"); 
  scanf("%f",&students[index].china_history); 
  getchar();
  if (59<students[index].china_history && students[index].china_history<100) 
  
   a3= 2.5;  
  
   else
  
   a3=0;
 

 printf(" Please enter military education :"); 
  scanf("%f",&students[index].junshi); 
  getchar();
  if (59<students[index].junshi && students[index].junshi<100) 
  
   a4= 2;  
  
   else
  {
   a4=0;
 }

 printf(" Please enter your mental health education score :"); 
  scanf("%f",&students[index].xinli); 
  getchar();
  if (59<students[index].xinli && students[index].xinli<100) 
  
   a5= 1.5;  
  
   else
  
   a5=0;
 
 printf(" Please enter your sports scores :"); 
  scanf("%f",&students[index].sports); 
  getchar();
  if (59<students[index].sports && students[index].sports<100) 
  
   a6= 2;  
  
   else
  
   a6=0;
 

 printf(" Please enter the C Language performance :"); 
  scanf("%f",&students[index].C_Mark); 
  getchar();
  if (59<students[index].C_Mark && students[index].C_Mark<100) 
  
   a7= 3.5;  
  
   else
  
   a7=0;
 
  
  printf(" Please enter the grade given by the head teacher :"); 
  scanf("%f",&students[index].Banzhuren); 
  getchar();
  students[index].pingjun=a1+a2+a3+a4+a5+a6+a7+a8; // Total credit  
  
  j=(students[index].pingjun*0.4)+(students[index].Banzhuren*0.6);
  students[index].Cepingfen=j; 

   } 

   printf(" Whether or not to continue ?(Y/N) Press any key to continue or enter N:"); 
   if (getchar()=='N') 
   { 
   break;
   } 

  } 

} 

/* Click the student number to delete student information */ 
void Student_Delete() 
{ 
 system("cls");
 system("color f0");
 IO_ReadInfo();
 int i; 
 while(1) 
 { 
  char id[20]; 
  int index; 
  printf(" Please enter the student number you want to delete :"); 
  scanf("%s",&id); 
  getchar(); 
  index=Student_SearchByIndex(id); 
  if (index==-1) 
  { 
   printf(" Students don't exist !\n"); 
  } 
  else 
  { 
   printf(" The student information you want to delete is :\n"); 
   Student_DisplaySingle(index); 
   printf("%d",index);
   printf("%d",num);
   { 
    for (i=index;i<num-1;i++) 
    { 
     students[i]=students[i+1];  // Move everything behind it forward  
    }
  
    num--; 
    } 
   printf(" deleted \n");
 
    IO_WriteInfo(); 
   } 

   printf(" Whether to continue deletion ?(Y/N) Press any key to continue or enter N:"); 
   if (getchar()=='N') 
   { 
   break;
   } 
  } 
} 

/* Delete student information by name */ 
void Student_Delete_1() 
{ 
 system("cls");
 system("color f0");
 IO_ReadInfo();
 int i; 
 while(1) 
 { 
  char name[20]; 
  int index; 
  printf(" Please enter the name of the student you want to delete : "); 
  scanf("%s",&name); 
  getchar(); 
  index=Student_SearchByName(name); 
  if (index==-1) 
  { 
   printf(" Students don't exist !\n"); 
  } 
  else 
  { 
   printf(" The student information you want to delete is :\n"); 
   Student_DisplaySingle(index); 
   { 
    for (i=index;i<num-1;i++) 
    { 
     students[i]=students[i+1];  // Move everything behind it forward  
    }
  
    num--; 
    } 
   printf(" deleted \n");
 
    IO_WriteInfo(); 
   } 

   printf(" Whether to continue deletion ?(Y/N) Press any key to continue or enter N:"); 
   if (getchar()=='N') 
   { 
   break;
   } 
  } 
} 


/* Enquiry by name */ 
void Student_Select_1() 
{ 
 while(1) 
 { 
  char name[20]; 
  int index; 

  printf(" Please enter the name of the student you want to check :"); 
  scanf("%s",&name); 
  getchar(); 
  index=Student_SearchByName(name); 

  if (index==-1) 
  { 
   printf(" Students don't exist !\n"); 
  } 
  else 
  { 
   printf(" The student information you want to query is :\n"); 
   Student_DisplaySingle(index); 
  } 

  printf(" Whether or not to continue ?(Y/N) Press any key to continue or enter N:"); 
  if (getchar()=='N') 
  { 
   break;
  } 

  }
} 
/* Search by student number */
void Student_Select_2() 
{
 while(1)
 {
  char ID[20];
  int index;
 
  system("cls");
  system("color f0"); 
  printf(" Please enter the student id of the student you want to check :"); 
  scanf("%s",&ID);
 getchar();
 index=Student_SearchByIndex(ID);
 
  if (index==-1) 
  { 
   printf(" Students don't exist !\n"); 
  } 
  else 
  { 
   printf(" The student information you want to query is :\n"); 
   Student_DisplaySingle(index); 
  } 

  printf(" Whether or not to continue ?(Y/N) Press any key to continue or enter N:"); 
  if (getchar()=='N') 
  { 
   break;
  } 

  }
 
}

void Student_Search_menu()
{
  int choice;
   while(1) 
 {
 system("cls");
  system("color f0");
 printf("\t\t\t\t\t\t1.  Search student records by name \n"); 
   printf("\t\t\t\t\t\t2.  Check student records by student number \n");
   printf("\t\t\t\t\t\t3.  On the back 1 menu \n");
 printf("\t\t\t\t\t\t4.  Go back to the main menu \n");
 printf("\t\t\t\t\t\t Please select a (1-4):");
 scanf("%d",&choice); 
   getchar();
 switch(choice)
 {
  case 1:Student_Select_1();
   break;
  
  case 2:Student_Select_2();
   break;
   
  case 3:Level_2_menu();
   break;
   
 case 4:Level_menu(); 
     break;
     
 } 
 } 
   
   
}

/* According to the C Language scores are ranked from highest to lowest */ 
void Student_From_high_to_low() 
{ 
 int i,j; 
 struct Student tmp; 

 for (i=0;i<num;i++) 
 { 
  for (j=1;j<num-i;j++) 
  { 
   if (students[j-1].C_Mark<students[j].C_Mark) 
   { 
    tmp=students[j-1]; 
    students[j-1]=students[j]; 
    students[j]=tmp; 
   } 
  } 
 } 
} 

/* According to the C Language scores are ranked from low to high */ 
void Student_From_low_to_high()
{
  int i,j; 
 struct Student tmp; 

 for (i=0;i<num;i++) 
 { 
  for (j=1;j<num-i;j++) 
  { 
   if (students[j-1].C_Mark>students[j].C_Mark) 
   { 
    tmp=students[j-1]; 
    students[j-1]=students[j]; 
    students[j]=tmp; 
   } 
  } 
 } 
 
} 


/* Rank the overall assessment from high to low */ 
void Student_From_high_to_low1() 
{ 
 int i,j,k; 
 struct Student tmp; 

 for (i=0;i<num;i++) 
 { 
  for (j=1;j<num-i;j++) 
  { 
   if (students[j-1].Cepingfen<students[j].Cepingfen) 
   { 
    tmp=students[j-1]; 
    students[j-1]=students[j]; 
    students[j]=tmp; 
   } 
  } 
 }
 
 /*system("cls");
 system("color f0");
 while(1) 
 { 
 int k; 
 printf("%10s%10s %8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n"," Student id "," The name "," The dormitory no. ","  Higher mathematics "," The university English "," Introduction to Software Technology "," Modern Chinese history "," Military education "," Mental health education "," College sports ","C Language performance "," conduct "," Head teacher grade "," The measurement points "); 
 printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"); 
 for (k=0;k<num;k++) 
 { 
 if(59<students[k].mathA1&&students[k].mathA1<101&&59<students[k].EnglishA1&&students[k].EnglishA1<101&&59<students[k].software&&students[k].software<101&&59<students[k].china_history&&students[k].china_history<101&&59<students[k].junshi&&students[k].junshi<101&&59<students[k].xinli&&students[k].xinli<101&&59<students[k].sports&&students[k].sports<101&&59<students[k].C_Mark&&students[k].C_Mark<101); 
  {
 printf("%10s%10s %8s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[k].ID,students[k].Name,students[k].sushe,students[k].mathA1,students[k].EnglishA1,students[k].software,students[k].china_history,students[k].junshi,students[k].xinli,students[k].sports,students[k].C_Mark,students[k].pingjun,students[k].Banzhuren,students[k].Cepingfen); 
  }
 }
  printf(" Data loaded! ");
 jiangxue_menu(); 
  Student_Tongji_menu3();
  
 } */
}


/* Evaluation Method of Scholarship */
void jiangxue_menu()
{
 float i=0,j=0,k=0;
 int a,b,c;
 i=num*0.1;
 j=num*0.15;
 k=num*0.2;
 a=(int)i;
 b=(int)j;
 c=(int)k;
 printf("1 The number of winners is: %d\n",a);
 printf("2 The number of prize winners is: %d\n",b);
 printf("3 The number of prize winners is: %d\n",c);
 
 
 
 
}
// Sift out those who have passed the scholarship  
void jiangxue()
{
 system("cls");
 system("color f0");
 while(1) 
 { 
 int k; 
 printf("%10s%10s %8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n"," Student id "," The name "," The dormitory no. ","  Higher mathematics "," The university English "," Introduction to Software Technology "," Modern Chinese history "," Military education "," Mental health education "," College sports ","C Language performance "," conduct "," Head teacher grade "," The measurement points "); 
 printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"); 
 for (k=0;k<num;k++) 
 { 
 if(59<students[k].mathA1&&students[k].mathA1<101&&59<students[k].EnglishA1&&students[k].EnglishA1<101&&59<students[k].software&&students[k].software<101&&59<students[k].china_history&&students[k].china_history<101&&59<students[k].junshi&&students[k].junshi<101&&59<students[k].xinli&&students[k].xinli<101&&59<students[k].sports&&students[k].sports<101&&59<students[k].C_Mark&&students[k].C_Mark<101); 
  {
 printf("%10s%10s %8s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[k].ID,students[k].Name,students[k].sushe,students[k].mathA1,students[k].EnglishA1,students[k].software,students[k].china_history,students[k].junshi,students[k].xinli,students[k].sports,students[k].C_Mark,students[k].pingjun,students[k].Banzhuren,students[k].Cepingfen); 
  }
 }
  printf(" Data loaded! ");
 jiangxue_menu(); 
  Student_Tongji_menu3();
  
 }
}

/* Display student information */ 
void Student_Display() 
{ 

 system("cls");
 system("color f0");
 while(1) 
 { 
 int i; 
 printf("%10s%10s %8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n"," Student id "," The name "," The dormitory no. ","  Higher mathematics "," The university English "," Introduction to Software Technology "," Modern Chinese history "," Military education "," Mental health education "," College sports ","C Language performance "," conduct "); 
 printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"); 
 for (i=0;i<num;i++) 
 { 
 printf("%10s%10s %8s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[i].ID,students[i].Name,students[i].sushe,students[i].mathA1,students[i].EnglishA1,students[i].software,students[i].china_history,students[i].junshi,students[i].xinli,students[i].sports,students[i].C_Mark,students[i].pingjun); 
 }
  printf(" Whether or not to continue ?(Y/N) Press any key to continue or enter N:"); 
  if (getchar()=='N') 
  { 
   break;
  } 
 }
  
} 

/* Display student information 1*/ 
void Student_Display1() 
{ 

 system("cls");
 system("color f0");
 while(1) 
 { 
 int i; 
 printf("%10s%10s %8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n"," Student id "," The name "," The dormitory no. ","  Higher mathematics "," The university English "," Introduction to Software Technology "," Modern Chinese history "," Military education "," Mental health education "," College sports ","C Language performance "," conduct "," Head teacher grade "," The measurement points "); 
 printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"); 
 for (i=0;i<num;i++) 
 { 
 printf("%10s%10s %8s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[i].ID,students[i].Name,students[i].sushe,students[i].mathA1,students[i].EnglishA1,students[i].software,students[i].china_history,students[i].junshi,students[i].xinli,students[i].sports,students[i].C_Mark,students[i].pingjun,students[i].Banzhuren,students[i].Cepingfen); 
 }
  printf(" Data loaded! "); 
  Student_Tongji_menu3();
  
 }
  
} 

/* Display student information 2 Used in scholarship evaluation */ 
void Student_Display2() 
{ 

 system("cls");
 system("color f0");
 while(1) 
 { 
 int i; 
 printf("%10s%10s %8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n"," Student id "," The name "," The dormitory no. ","  Higher mathematics "," The university English "," Introduction to Software Technology "," Modern Chinese history "," Military education "," Mental health education "," College sports ","C Language performance "," conduct "," Head teacher grade "," The measurement points "); 
 printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"); 
 for (i=0;i<num;i++) 
 { 
 printf("%10s%10s %8s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[i].ID,students[i].Name,students[i].sushe,students[i].mathA1,students[i].EnglishA1,students[i].software,students[i].china_history,students[i].junshi,students[i].xinli,students[i].sports,students[i].C_Mark,students[i].pingjun,students[i].Banzhuren,students[i].Cepingfen); 
 }
  printf(" Data loaded! ");
 jiangxue_menu(); 
  Student_Tongji_menu3();
  
 }
  
} 
/* Transfer student information from the file ( student database.txt ) read */ 
void IO_ReadInfo() 
{ 
 FILE *fp; 
 int i; 

 if ((fp=fopen("student database.txt","rb"))==NULL) 
 { 
  printf(" Can't open a file !\n"); 
  return; 
 }

 if (fread(&num,sizeof(int),1,fp)!=1) 
 { 
  num=-1; 
 } 
 else 
 { 
  for(i=0;i<num;i++) 
  { 
   fread(&students[i],sizeof(struct Student),1,fp); 
  } 
 } 

 fclose(fp); 
} 

/* Write student information to a file ( Database.txt ) */ 
void IO_WriteInfo()
{ 
 FILE *fp; 
 int i; 
 if ((fp=fopen("student database.txt","wb"))==NULL) 
 { 
  printf(" Can't open a file !\n"); 
  return; 
 } 
 if (fwrite(&num,sizeof(int),1,fp)!=1) 
 { 
  printf(" Error writing to file !\n"); 
 } 
 for (i=0;i<num;i++) 
 { 
  if (fwrite(&students[i],sizeof(struct Student),1,fp)!=1) 
  { 
   printf(" Error writing to file !\n"); 
  } 
 } 
 fclose(fp); 
}
 /*1 menu */ 
 /* Account password login */
void Level_1_menu( )
{ char account[20];
 char password[30];
 int i = 0;
 int j = 3;
 for (; i < 3; i++){
  printf("\n\n\n\n\t\t\t\t\t\t  * The main menu *\n");
 printf("\t\t\t\t\t\t******************\n");
 printf("\t\t\t\t\t\t* Please enter your account number: *\n");
 printf("\t\t\t\t\t\t******************\n");
 printf("             Please enter the :"); 
 scanf ("%s", account);
 printf("\t\t\t\t\t\t******************\n");
 //scanf ("%s", account);
 printf("\t\t\t\t\t\t******************\n");
 printf("\t\t\t\t\t\t* Please enter your password: *\n"); 
 printf("\t\t\t\t\t\t******************\n");
 printf("             Please enter the :"); 
 scanf ("%s", password);
 if (strcmp(USER, account) == 0 && strcmp(PW, password) == 0){
 printf(" Login successful! \n");
 break;
 }
 else{
 j--;
 printf(" Logon failure you still have %d Second chance! \n", j);
 }
 }
 if (i == 3){
 printf(" Login failed, log out! ");
 }
 //system("pause");
 system("cls");
 system("color f0"); 
}
/* Add student information 3 Level menu module */ 
 
void Student_add_Level_3_menu()
 {
  int choice;
   while(1) 
 {
 system("cls");
  system("color f0");
  IO_ReadInfo();  // Read the file  
 printf("\t\t\t\t\t\t1.  Add student information individually \n"); 
   printf("\t\t\t\t\t\t2.  Add student information in batch \n");
   printf("\t\t\t\t\t\t3.  On the back 1 menu \n");
 printf("\t\t\t\t\t\t4.  Go back to the main menu \n");
 printf("\t\t\t\t\t\t Please select a (1-4):");
 scanf("%d",&choice); 
   getchar();
 switch(choice)
 {
  case 1:Student_Insert();
   IO_WriteInfo();  // Written to the file  
   break;
  
  case 2:Student_many1();
   IO_WriteInfo();  // Written to the file 
   break;
   
  case 3:Level_2_menu();
   break;
   
 case 4:Level_menu(); 
     break;
     
 }
 IO_WriteInfo();  // Written to the file  
 } 
   //Student_Insert(); 
   
 }

  /*2 menu */ 
  /* The main menu */
void Level_2_menu( )
{
int choice;
 while(1) 
 { 
  /*2 menu */ 
  /* The main menu */
 system("cls");
  system("color f0");
 IO_ReadInfo();  // Read the file  
  printf("\n\t\t\t\t\t\t------  Student achievement management system ------\n"); 
  printf("\t\t\t\t\t\t1.  Add student records \n"); 
  printf("\t\t\t\t\t\t2.  Revision of student records \n"); 
  printf("\t\t\t\t\t\t3.  Delete student records \n");
 printf("\t\t\t\t\t\t4.  Access to Student records \n"); 
  printf("\t\t\t\t\t\t5.  Statistical Student Records \n"); 
  printf("\t\t\t\t\t\t6.  exit \n"); 
  printf("\t\t\t\t\t\t Please select a (1-6):"); 

  scanf("%d",&choice); 
  getchar(); 

  switch(choice) 
  { 
  case 1:
   Student_add_Level_3_menu();
   break; 

  case 2: 
   Student_Modify(); 
   break; 

  case 3: 
   student_Delete_menu(); 
   break; 

  case 4: 
   Student_Search_menu();
   break; 

  case 5:
  Student_Tongji_menu();
 break; 
 
  case 6: 
   Level_menu(); 
   break;

  }
 IO_WriteInfo(); 
 } 
}

/* Student end result query module */
void student_Delete_menu()
{
 int choice; 
 while(1)
 {
 system("cls");
  system("color f0");
  IO_ReadInfo();  // Read the file 
 printf("\n\n\n\n\t\t\t\t\t\t************************\n");  
  printf("\t\t\t\t\t\t*  Delete the student information menu ******\n");
 printf("\t\t\t\t\t\t************************\n");
  printf("\t\t\t\t\t\t*1 , delete information by name   *\n");
 printf("\t\t\t\t\t\t*2 , delete information according to the student number   *\n");
 printf("\t\t\t\t\t\t*3 , return on 1 Level function menu  *\n");
 printf("\t\t\t\t\t\t*4 , return to the main menu    *\n");
 printf("\t\t\t\t\t\t************************\n");
 printf("\t\t\t\t\t\t************************\n"); 
 printf("             Please select a (1-4):"); 
 scanf("%d",&choice);
 
 switch(choice) 
  { 
  case 1:
  system("cls");
   system("color f0");
    Student_Delete_1();
    break;
  case 2:
   system("cls");
   system("color f0");
   Student_Delete(); 
   break;
  case 3:
    Level_2_menu(); 
    break;
    
  case 4:
    Level_menu(); 
    break;  
  }
  
 IO_WriteInfo(); 
 } 
 }
 

/* Student end result query module */
void student_menu()
{
 int choice; 
 while(1)
 {
 system("cls");
  system("color f0");
  IO_ReadInfo();  // Read the file 
 printf("\n\n\n\n\t\t\t\t\t\t*******************\n");  
  printf("\t\t\t\t\t\t*   The student menu  *\n");
 printf("\t\t\t\t\t\t*******************\n");
  printf("\t\t\t\t\t\t*1 , search results by name *\n");
 printf("\t\t\t\t\t\t*2 , press the student number to inquire the result *\n");
 printf("\t\t\t\t\t\t*3 , check course information  *\n");
 printf("\t\t\t\t\t\t*4 , exit    *\n");
 printf("\t\t\t\t\t\t*******************\n");
 printf("\t\t\t\t\t\t*******************\n"); 
 printf("             Please select a (1-3):"); 
 scanf("%d",&choice);
 
 switch(choice) 
  { 
  case 1:
  system("cls");
   system("color f0");
    Student_Select_1();
    break;
  case 2:
   Student_Select_2();
   break;
   
  case 3:
    student_menu1();
  break; 
   
  case 4:
    Level_menu(); 
    break;
  }
  
 IO_WriteInfo(); 
 } 
 }

 

void student_Kecheng_menu1()
{ printf("\n\n\n\n\t\t\t\t\t\t************************************************\n");
 printf("\t\t\t\t\t\t*  Class code    Course name    credits   compulsory / take *\n");
 printf("\t\t\t\t\t\t*B27020100  Outline of Modern and Contemporary Chinese history  2.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B10060111  The university English A1   4.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B14010101  College sports 1   2.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B06010111  Higher mathematics A1   5.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B08050101  Introduction to Software Technology   2.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B08010100 C Language programming   5.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B08010201 C Language programming training 1 2.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B08056601  Innovation and guiding practice 1 1.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B21991100  Military education    2.0   take  *\n");
 printf("\t\t\t\t\t\t**************************************************\n");
 printf("\t\t\t\t\t\t**************************************************\n");
 printf("\t\t\t\t\t\t1.  On the back 1 menu \n");
 printf("\t\t\t\t\t\t2.  Go back to the main menu \n");
 printf("\t\t\t\t\t\t Please select a (1-2):");
  int choice;
 scanf("%d",&choice);
 while(1) 
   
 switch(choice)
 
 {
 
   
  case 1:student_menu1();
   break;
   
 case 2:Level_menu(); 
     break;
     
 }
  // Written to the file 
}

void student_Kecheng_menu2()
{ printf("\n\n\n\n\t\t\t\t\t\t************************************************\n");
 printf("\t\t\t\t\t\t*  Class code    Course name    credits   compulsory / take *\n");
 printf("\t\t\t\t\t\t*B27010100  Ideological and moral cultivation   3.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B10060112  The university English A2   4.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B14010102  College sports 2   2.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B06010112  Higher mathematics A2   5.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B08052200  Digital logic design   2.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B06050131  University physics C1   2.5   compulsory  *\n");
 printf("\t\t\t\t\t\t*B06020100  Discrete mathematics    4.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B08056601  Innovation and guiding practice 2 1.0   compulsory  *\n");
 printf("\t\t\t\t\t\t*B21991100 C Language programming practices 2 2.0   take  *\n");
 printf("\t\t\t\t\t\t**************************************************\n");
 printf("\t\t\t\t\t\t**************************************************\n");
 printf("\t\t\t\t\t\t1.  On the back 1 menu \n");
 printf("\t\t\t\t\t\t2.  Go back to the main menu \n");
 printf("\t\t\t\t\t\t Please select a (1-2):");
  int choice;
 scanf("%d",&choice);
 while(1) 
   
 switch(choice)
 
 {
 
   
  case 1:student_menu1();
   break;
   
 case 2:Level_menu(); 
     break;
     
 }
  // Written to the file 
}
 
 
/* Student side student course inquiry module */
void student_menu1()
{
 int choice; 
 while(1)
 {
 system("cls");
  system("color f0");
  IO_ReadInfo();  // Read the file 
 printf("\n\n\n\n\t\t\t\t\t\t*******************\n");  
  printf("\t\t\t\t\t\t*   Course information  *\n");
 printf("\t\t\t\t\t\t*******************\n");
  printf("\t\t\t\t\t\t*1 And the first 1 semester   *\n");
 printf("\t\t\t\t\t\t*2 And the first 2 semester   *\n");
 printf("\t\t\t\t\t\t*3 And the first 3 semester   *\n");
 printf("\t\t\t\t\t\t*4 And the first 4 semester   *\n");
 printf("\t\t\t\t\t\t*5 And the first 5 semester   *\n");
 printf("\t\t\t\t\t\t*6 And the first 6 semester   *\n");
 printf("\t\t\t\t\t\t*7 And the first 7 semester   *\n");
 printf("\t\t\t\t\t\t*8 , exit    *\n");
 printf("\t\t\t\t\t\t*******************\n");
 printf("\t\t\t\t\t\t*******************\n"); 
 printf("             Please select a (1-3):"); 
 scanf("%d",&choice);
 
 switch(choice) 
  { 
  case 1:
  system("cls");
   system("color f0");
    student_Kecheng_menu1();
    break;
  case 2:
   system("cls");
   system("color f0");
   student_Kecheng_menu2();
   break;
  case 3:
    
    break;
  case 4:
    
    break;
  case 5:
     
    break;
  case 6:
     
    break;
  case 7:
     
    break;
  case 8:
    Level_menu(); 
    break;
   
  }
  
 IO_WriteInfo(); 
 } 
 }
 
/* Statistical Menu module */
void Student_Tongji_menu()
{
 int choice; 
 while(1)
 {
 system("cls");
  system("color f0");
  IO_ReadInfo();  // Read the file 
 printf("\n\n\n\n\t\t\t\t\t\t******************************\n");  
  printf("\t\t\t\t\t\t*   Student statistical menu   *\n");
 printf("\t\t\t\t\t\t******************************\n");
  printf("\t\t\t\t\t\t*1 And according to the C Language scores are ranked from highest to lowest  *\n");
 printf("\t\t\t\t\t\t*2 And according to the C Language scores are ranked from low to high  *\n");
 printf("\t\t\t\t\t\t*3 , according to the members of the dormitory   *\n");
 printf("\t\t\t\t\t\t*4 · Scholarship Evaluation     *\n"); 
 printf("\t\t\t\t\t\t*5 , return to the function menu     *\n");
 printf("\t\t\t\t\t\t*6 , return to the main menu     *\n");
 printf("\t\t\t\t\t\t******************************\n");
 printf("\t\t\t\t\t\t******************************\n"); 
 printf("             Please select a (1-5):"); 
 scanf("%d",&choice);
 
 switch(choice) 
  { 
  case 1: 
   Student_From_high_to_low();
   Student_Display1();
   break;
    
  case 2:
   Student_From_low_to_high();
  Student_Display1();
  break;
  
 case 3:
   Student_SearchBySushe();
  break;
  
 case 4:
  
   Student_From_high_to_low1();
  Student_Display2(); 
    break;
     
  case 5:
   Level_2_menu( ); 
    break;
    
  case 6:
    Level_menu(); 
    break;
    
  }
  
 IO_WriteInfo(); 
 } 
 }
 
/* Statistical Menu module */
void Student_Tongji_menu2()
{
 int choice; 
 while(1)
 {
 
  IO_ReadInfo();  // Read the file 
 printf("\n\n\n\n\t\t\t\t\t\t******************************\n");  
  printf("\t\t\t\t\t\t*  You are currently on the student housing statistics page!  *\n");
 printf("\t\t\t\t\t\t******************************\n");
  printf("\t\t\t\t\t\t*1 , return on 1 Level statistics menu   *\n");
 printf("\t\t\t\t\t\t*2 , return to the menu of function selection    *\n");
 printf("\t\t\t\t\t\t*3 , return to the main menu     *\n");
 printf("\t\t\t\t\t\t******************************\n");
 printf("\t\t\t\t\t\t******************************\n"); 
 printf("             Please select a (1-3):"); 
 scanf("%d",&choice);
 
 switch(choice) 
  { 
  case 1: 
    system("cls");
   system("color f0");
   Student_Tongji_menu(); 
    
  case 2:
   system("cls");
   system("color f0");
   Level_2_menu( );
  
 case 3:
   system("cls");
   system("color f0");
   Level_menu();
  }
  
 } 
 }
 
/* Statistical Menu module */
void Student_Tongji_menu3()
{
 int choice; 
 while(1)
 {
 
  IO_ReadInfo();  // Read the file 
 printf("\n\n\n\n\t\t\t\t\t\t******************************\n");  
  printf("\t\t\t\t\t\t*  You are currently in C Language score statistics page! *\n");
 printf("\t\t\t\t\t\t******************************\n");
  printf("\t\t\t\t\t\t*1 , return on 1 Level statistics menu   *\n");
 printf("\t\t\t\t\t\t*2 , return to the menu of function selection    *\n");
 printf("\t\t\t\t\t\t*3 , return to the main menu     *\n");
 printf("\t\t\t\t\t\t******************************\n");
 printf("\t\t\t\t\t\t******************************\n"); 
 printf("             Please select a (1-3):"); 
 scanf("%d",&choice);
 
 switch(choice) 
  { 
  case 1: 
    system("cls");
   system("color f0");
   Student_Tongji_menu(); 
    
  case 2:
   system("cls");
   system("color f0");
   Level_2_menu( );
  
 case 3:
   system("cls");
   system("color f0");
   Level_menu();
  }
  
 } 
 } 
 
 
/* The first 1 Main menu students or Teacher's judgment */ 
void Level_menu()
{  int choice;
  while(1)
 { 
 system("cls");
  system("color f0");
  printf("\n\n\n\n\n\n\n\t\t\t\t\t\t******************\n");
 printf("\t\t\t\t\t\t*1 , teachers end   *\n");
 printf("\t\t\t\t\t\t*2 And students end   *\n");
 printf("\t\t\t\t\t\t*3 , exit    *\n");
 printf("\t\t\t\t\t\t******************\n");
 printf("             Please select a (1-3):"); 
 scanf("%d",&choice);
 switch(choice)
 {
  case 1:
   system("cls");
   system("color f0");  
     Level_1_menu(); //1 Level menu, password login.  
     IO_ReadInfo();   // Read the file 
     Level_2_menu(); //2 menu - The main menu  
     IO_WriteInfo();
  break;
  
 case 2:
  student_menu();
  break; 
 case 3:
  exit(0); 
     break;  
 } 
 } 
 } 


 
/*********** The main program *********/ 
main() 
{ 
 Level_menu();
}

For more information about the management system, please click "Management system Topics" to learn


Related articles: