Home > Back-end >  , help to have a look at the code where there is a problem
, help to have a look at the code where there is a problem

Time:11-23

 # include & lt; stdio.h> 
#include
#include

//grade structure
Struct score
{
Char ID [11];
Char Name [25];
Char banji [10].
Int gs;
Int wy.
Int wl;
Int cx.
Int x;
Int zz.

};

//function declaration
Void welcome ();//main menu
Void yl (int);//achievement preview
Void cx (int);//scores query
Void what zj had (int);//increase achievement
Int sc (int);//delete grades
Int xg (int);//modify result
Void BCCJ (void);//save scores and exit
Void showcxmenu (void);//the secondary menu, query menu
Void XMCX (int n);//query name
Void XHCX (int);//student id query
//the main function
Int main ()
{
Int flag, n=0, count=0;//flag flags, count count, the current total number of
//-- -- -- -- -- -- -- -- -- -- -- -- -- to determine how many files inside record -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --//
FILE *fp;
Fp=fopen (" 111. TXT ", "a +");
If (fp==NULL)
{
Printf (" failed to open the file, please try again! \n");
getchar();
fclose(fp);
exit(0);
}
Int c=0;
while(! The feof (fp))
{
Char cc=fgetc (fp);
If (EOF) cc==
{
break;
}
//output characters
//putchar (cc);
C + +;
}
The count=c/14;
//printf (" % d ", count);
//getch ();
fclose(fp);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --//
Do
{
Welcome ();
The scanf (" % d ", & amp; The flag);//enter
The switch (flag)
{
Case 1: printf (" please enter your to input the number of people: ");
The scanf (" % d ", & amp; n);
What zj had (n);
Count +=n; break;
Case 2: count=sc (count); Printf (" % d ", count); break;
Case 3: xg (count); break;
Case 4: cx (count); break;
Case 5: yl (count); break;
Case 0: BCCJ (); break;
Default: printf (" input error, please try again! \n"); Getch ();
}
} while (flag!=0);
Getch ();
return 0;
}

//0 display menu
Void welcome ()
{
//system (" CLS ");
Printf (" * * * * * * * * * * * * * welcome to use student achievement management system * * * * * * * * * * * * * * * * * \ n ");
Printf (" * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * \ n ");
Printf (" * 1. Input scores * \ n ");
Printf (" * 2. Delete results * \ n ");
Printf (" * 3. The modified result * \ n ");
Printf (" * 4. Scores query * \ n ");
Printf (" * * 5. According to performance information \ n ");
Printf (" * * 0. Save the information and exit system \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * welcome to * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf (" select operation & lt; 0 to 6 & gt; \n");
return;
}

//1 increase achievement
Void what zj had (int n)
{
Struct score stu [100].
FILE *fp;
Fp=fopen (" 111. TXT ", "a +");
If (fp==NULL)
{
Printf (" failed to open the file, please try again! \n");
getchar();
fclose(fp);
exit(0);
}
Printf (" please enter all the student's student id, name, class, number of high grades, foreign language performance, physical performance, application result, thought achievement, the achievement; \n");
int i;
for(i=0; i{
Printf (" -- -- the first % d students - \ n ", I + 1);
Printf (" student number: ");
The scanf (" % s ", & amp; Stu [I]. ID);

Printf (" name: ");
The scanf (" % s ", & amp; Stu [I] Name);

Printf (" class: ");
The scanf (" % s ", & amp; Stu [I] banji);

Printf (" high number grade: ");
The scanf (" % d ", & amp; Stu [I]. Gs);

Printf (" foreign language achievement: ");
The scanf (" % d ", & amp; Stu [I]. Wy);

Printf (" physical performance: ");
The scanf (" % d ", & amp; Stu [I]. Wl);

Printf (" program performance: ");
The scanf (" % d ", & amp; Cx); stu [I].

Printf (" fix performance: ");
The scanf (" % d ", & amp; Stu [I] sx);

Printf (" the result: ");
The scanf (" % d ", & amp; Stu [I]. Zz);

//write data
Fprintf (fp, "% s % s % s % d % d % d % d % d % d \ n", stu [I] ID, stu [I]. Name, stu [I] banji, stu [I]. Gs, stu [I]. Wy, stu [I]. Wl, stu [I] cx, stu [I] sx, stu [I] zz); }
fclose(fp);
Printf (" add student success, please press any key to return to the \ n ");
getchar();
}

//delete grades 2
Int sc (int n)
{
Struct score stu [100].
Struct score sub [99];//delete after the structure of array
Char ID [10];//student id
int find=0;
Printf (" please input you want to delete the student student number: ");
The scanf (" % s ", & amp; ID);
FILE *fp;
Fp=fopen (" 111. TXT ", "r");
If (fp==NULL)
{
Printf (" failed to open the file, please contact your administrator \ n ");
getchar();
return -1;
}
Int c=0;
Int index=0;//used to record the target number
while(! Feof (fp))//no empty
{
Fscanf (fp, "% s % s % s % d % d % d % d % d % d \ n", & amp; Stu [c]. ID, & amp; Stu [c]. Name, & amp; Stu [c]. Banji, & amp; Stu [c]. Gs, & amp; Stu [c]. Wy, & amp; Stu [c]. Wl, & amp; Cx, stu [c]. & amp; Stu [c]. Sx, & amp; Stu [c]. Zz);
If (STRCMP (ID, stu [c]. ID)==0)
{
The find=1;//according to the student id to find, find assignment 1
The index=c;//record number
}
C + +;
}
fclose(fp);
If (n==0)
{
Printf (" there is no student achievement information, please press any key to return to the \ n ");
Getch ();
Welcome ();
return n;
}
If (find==0)
{
Printf (" not the student achievement information, please press any key to return to the \ n ");
Getch ();
Welcome ();
return n;
}
The else
{
int i;
//delete
for(i=0; i{
If (I & lt; The index)
{
Sub [I]=stu [I];
}
The else
{
Sub [I]=stu [I + 1);
}
}

Fp=fopen (" 111. TXT ", "w");
//write data
for(i=0; i{
Fprintf (fp, "% s % s % s % d % d % d % d % d % d \ n", stu [I] ID, stu [I]. Name, stu [I] banji, stu [I]. Gs, stu [I]. Wy, stu [I]. Wl, stu [I] cx, stu [I] sx, stu [I] zz);
}
fclose(fp);
Printf (" the student achievement delete student ID for % s is successful, please press any key to return to the \ n ", ID);
Getch ();
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull