SoFunction
Updated on 2025-03-10

Implementing student academic qualification management system in C language

This article shares the specific code for implementing student academic record management system in C language for your reference. The specific content is as follows

#include<> 
#include<> 
#include<> 
#include<> 
#include<> 
 
 
//*************************** Structure******************************************struct score 
{ 
 char class_num[10]; 
 char person_num[10]; 
 char name[15]; 
 char sex; 
 int num; 
}stu; 


//***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************void print1()            //Output account function{ 
printf("Class Student ID Name Gender Score\n"); 
} 

//*****************************menu********************************************int menu()             //Menu Function{ 
 
 char i; 
 printf("\n\n\n\n"); 
 puts("\t\t********************* Main Menu*********************\t\n"); 
 puts("\t\t\t\t1.Student information input \n"); 
 puts("\t\t\t\t2. Student Information Browse \n"); 
 puts("\t\t\t\t3.Student Information Retrieval \n"); 
 puts("\t\t\t\t4. Student Information Modification \n"); 
 puts("\t\t\t\t5. Student Information Delete \n"); 
 puts("\t\t\t\t6. Exit system\n"); 
 puts("\t\t**********************************************\t\n"); 
 printf("\t\t\tPlease select (1-6):[ ]\b\b"); 
 i=getchar(); 
 system("cls"); 
 return i; 
} 

//************************ Input function******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************void Enter() 
{ 
 
 FILE *fp; 
 char ch; 
 if((fp=fopen("f:\\","a+"))==NULL) 
 { 
  printf("\nCannot open file!\n"); 
  getch(); 
  exit(1); 
 } 
 do 
 { 
  printf("Please enter class:");scanf("%s",stu.class_num);getchar(); 
  printf("\n"); 
  printf("Please enter the student number:");gets(stu.person_num); 
  printf("\n"); 
  printf("Please enter your name:");gets(); 
  printf("\n"); 
  printf("sex  Don't(m/f):");scanf("%c",&);getchar(); 
  printf("\n"); 
  printf("Fraction:");scanf("%d",&);getchar(); 
  printf("\n"); 
  fwrite(&stu,sizeof(stu),1,fp); 
  printf("continue(y/n)?[ ]\b\b"); 
  ch=getchar(); getchar(); 
 }while(ch=='y'||ch=='Y'); 
 fclose(fp); 
 system("cls"); 
} 
 
 
 
//***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************void Browse() 
{ 
 
FILE *fp; 
int total=0; 
if((fp=fopen("f:\\","a+"))==NULL) 
{ 
 printf("\tCan not open the inform file!"); 
 getch(); 
 exit(1); 
} 
while(fread(&stu,sizeof(stu),1,fp)==1) 
{ 
 total++; 
 if(total==1) 
 print1(); 
 printf("%-10s%-10s%-20s",stu.class_num,stu.person_num,); 
 printf("%-8c",); 
 printf("%-4d ",); 
 printf("\n"); 
} 
fclose(fp); 
printf("\n\n\tThere are %d records in total!\n",total); 
printf("\tpress any key to continue!"); 
getchar(); 
getchar(); 
system("cls"); 
 
} 
 
 
//*********************Query function*********************************************************************void Query() 
{ 
 FILE * fp; 
 char num1[10]; 
 char ch; 
if((fp=fopen("f:\\","a+"))==NULL) 
{ 
 printf("\tCan not open the inform file!"); 
 getch(); 
 exit(1); 
} 
do 
{ 
 getchar(); 
 rewind(fp); 
 printf("\nPlease enter the student number to query:"); 
 gets(num1); 
 while(fread(&stu,sizeof(stu),1,fp)==1) 
  if(strcmp(num1,stu.person_num)==0) 
  { 
   print1(); 
   printf("%-10s%-10s%-20s",stu.class_num,stu.person_num,); 
   printf("%-8c",); 
   printf("%-4d ",); 
   printf("\n"); 
   break; 
  } 
  puts("\n"); 
 printf("continue查询?(Y/N):[ ]\b\b"); 
 ch=getchar(); 
}while(ch=='Y'||ch=='y'); 
fclose(fp); 
system("cls"); 
} 
 
 
//************************ Student grade modification function*************************************************************** 
void Recopose() 
{ 
  FILE * fp1,* fp2; 
  char num1[10]; 
  char ch; 
  getchar(); 
 do 
 { 
  if((fp1=fopen("f:\\","a+"))==NULL) 
  { 
  printf("\tCan not open the infom file!"); 
  getch(); 
  exit(1); 
  } 
  if((fp2=fopen("f:\\","a+"))==NULL) 
  { 
  printf("\tCan not creat the temp file!"); 
  getch(); 
  exit(1); 
  } 
  printf("Please enter the student number you want to modify:"); 
  gets(num1); 
while(fread(&stu, sizeof(stu),1,fp1)==1) 
{ 
  if(strcmp(num1,stu.person_num)==0) 
  { 
   print1(); 
   printf("%-10s%-10s%-20s",stu.class_num,stu.person_num,); 
   printf("%-8c",); 
   printf("%-4d ",); 
   printf("\n"); 
   printf("\n\nPlease input the new information:\n"); 
   printf("\tClass Code:");gets(stu.class_num); 
   printf("\tStudent Student Number:");gets(stu.person_num); 
   printf("\tStudent name:"); gets(); 
   printf("\tStudent Gender:");gets(&); 
   printf("\tStudent grades:");scanf("%d",&); getchar(); 
  } 
 fwrite(&stu,sizeof(stu),1,fp2); 
 } 
 fclose(fp1); 
 fclose(fp2); 
 printf("Modification was successful!\n"); 
 remove("f:\\"); 
 rename("f:\\","f:\\"); 
 printf("continue修改?(Y/N):[ ]\b\b"); 
 ch=getchar(); getchar(); 
}while(ch=='Y'||ch=='y'); 
 system("cls"); 
} 
 
 
//***************************Delete function*********************************************************void Delete() 
{ 
  FILE * fp1,* fp2; 
  int flag; 
  char num1[10]; 
  char ch; 
  getchar(); 
  do 
  { 
  if((fp1=fopen("f:\\","a+"))==NULL) 
  { 
   printf("\tCan not open the inform file!"); 
   getch(); 
   exit(1); 
  } 
  if((fp2=fopen("f:\\","a+"))==NULL) 
  { 
   printf("\tCan not creat the temp file!"); 
   getch(); 
   exit(1); 
  } 
  printf("Please enter the student number of the student you want to delete:"); 
  gets(num1); 
  flag=0; 
  while(fread(&stu,sizeof(stu),1,fp1)==1) 
  { 
   if(strcmp(num1,stu.person_num)==0) 
   { 
    print1(); 
    printf("%-10s%-10s%-20s",stu.class_num,stu.person_num,); 
    printf("%-8c",); 
    printf("%-4d ",); 
    printf("\n"); 
    flag=1; 
   } 
   else 
    fwrite(&stu,sizeof(stu),1,fp2); 
  } 
  fclose(fp1); 
  fclose(fp2); 
  if(flag==1) 
  { 
   remove("f:\\"); 
   rename("f:\\","f:\\"); 
  } 
  else 
   printf("Can not find this record!\n"); 
  printf("continue删除?(Y/N):[ ]\b\b"); 
  ch=getchar(); getchar(); 
  }while(ch=='Y'||ch=='y'); 
  system("cls"); 
} 
 
 
//***********************************quit**************************************void Exit() 
{ 
 puts("\n\t\t\t\t\tThank you for using this system!!\n\n\t\t\t\tIf you have any questions, please contact: 1005483758@ \n"); 
 exit(0); 
} 
 
//******************Welcome interface******************************************void Welcome() 
{ 
  printf("\n\n"); 
 printf(" \t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n"); 
 printf(" \t┃**********************************************************┃\n"); 
 printf(" \t┃***┏━━━━━━━━━━━━━━━━━━━━━━━━┓***┃\n"); 
 printf(" \t┃***┃************************************************┃***┃\n"); 
 printf(" \t┃***┃***           ****┃***┃\n"); 
 printf(" \t┃******┃*** Welcome to the student achievement management system ****┃******┃\n"); 
 printf(" \t┃***┃***           ****┃***┃\n"); 
 printf(" \t┃***┃***           ****┃***┃\n"); 
 printf(" \t┃******┃***Producer: XXY ****┃***┃***\n"); 
 printf(" \t┃***┃***           ****┃***┃\n"); 
 printf(" \t┃***┃***      2013.6.20  ****┃***┃\n"); 
 printf(" \t┃***┃***           ****┃***┃\n"); 
 printf(" \t┃***┃************************************************┃***┃\n"); 
 printf(" \t┃***┗━━━━━━━━━━━━━━━━━━━━━━━━┛***┃\n"); 
 printf(" \t┃**********************************************************┃\n"); 
 printf(" \t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n"); 
 puts(" \n\t ① Administrator login! \n"); 
 puts(" \n\t ② Visitor Login! \n"); 
 printf("\nPlease select Login (1 or 2):[ ]\b\b"); / /Move one left“\b ” 
} 
 
//***************************Main function***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************int main() 
{ 
  int i,k=0; 
  char username[15],pwd[7],c; 
  system("color 5e");//color  Welcome(); 
   c=getchar();getchar(); 
  if (c=='1') 
  { 
   system("cls");//Jump the page.   puts("\n\n\n\n\n\n\n\n\t\t\t\t Administrator logs in!\n\n\n\n\n\t\t\t Please log in!"); 
   getchar(); 
   for(i=0;i<3;i++) 
    { 
      printf("\nPlease enter the username:"); 
     gets(username); 
     printf("\nPlease enter a 6-digit password:"); 
     gets(pwd); 
     //Judgement conditions     if((strcmp(username,"xiaxianyun")==0)&&(strcmp(pwd,"123456")==0)) 
     { 
      printf("\nYou have successfully logged in\n"); 
      k=1; 
      for(i=0;i<20;i++) 
      { 
        printf("."); 
        Sleep(100); 
      } 
     system("cls"); 
  
      while(1) 
      switch(menu()) 
      { 
       case '1':Enter();break; 
       case '2':Browse();break; 
       case '3':Query();break; 
       case '4':Recopose();break; 
       case '5':Delete();break; 
       case '6':Exit();break; 
      } 
      break; 
     } 
    else 
     printf("\nUsername or password is invalid Please re-enter:\n"); 
     continue; 
    } 
     if(k==0) 
    printf("\n3 consecutive input errors will be exited\n"); 
  Sleep(2000); 
  exit(1); 
  } 
  else if(c=='2')//Tourist login  { 
   system("cls");//Jump the page.   puts("\n\n\n\n\n\n\n\n\t\t\t\t Welcome tourists!\n\n\n\n\n\t\t Please confirm!"); 
   getchar(); 
   system("cls"); 
   while(1) 
    switch(menu()) 
    { 
     case '1':Enter();break; 
     case '2':Browse();break; 
     case '3':Query();break; 
     case '4':system("cls");getchar(); 
     puts("\n\n\t\t Sorry you don't have permission to modify it!\n\n"); 
     printf("\t\tpress any key to continue!");getchar();system("cls");break; 
     case '5':system("cls");getchar(); 
     puts("\n\n\t\t Sorry you don't have permission to delete it!\n\n"); 
     printf("\t\tpress any key to continue!");getchar();system("cls");break; 
     case '6':Exit();break; 
    } 
  }  
 return 0; 
} 

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.