Home > Back-end >  C program, this program won't run on my computer, who can help me have a look at where there is
C program, this program won't run on my computer, who can help me have a look at where there is

Time:10-07

#include
#include
#include
The class Student
{
Private:
Int num.
Char name [10].
Int score;
Public:
Student () {};
Friend void Daolu ();
Friend void Liulan ();
Friend void Chaxun ();
Friend void Xiugai ();
Friend void Shanchu ();
To the Student () {};
};
Student stu [80].
Void Daolu ()
{
Ofstream out;
Out. The open (" stu. TXT ", the ios: : ate);
Int m=1;
for(int i=0; i<=79 & amp; & M==1; I++)
{
Cout<" Please input the student student id: ";
Cin> Stu [I] num;
Cin. The get ();
Cout<" Enter the student's name: ";
Cin. Getline (stu [I]. Name, 10);
Cout<" Input the student achievement: ";
Cin> Stu [I] score;
Out. Write ((char *) & amp; Stu [I], sizeof (stu [I]));
Cout<" Whether to continue the input? Press 1, no press 0: ";
Cin> M;
}
out.close();
}
Void Liulan ()
{
Ifstream in;
In the open (" stu. TXT ");
if(! In) cout<" Can 't open the file!" & lt; & lt; Endl;
Int I=0;
while(! In the eof ())
{
In the read ((char *) & amp; Stu [I], sizeof (stu [I]));
If (stu [I] num!=0)
{
Cout<" Student: student id "& lt; & lt; Stu [I] num<& lt; Endl<" Student's name: "& lt; & lt; Stu [I] name<& lt; Endl<" Student achievement: "& lt; & lt; Stu [I] score<& lt; Endl;
i++;
}
}
in.close();
}
Void Chaxun ()
{
Ifstream in;
In the open (" stu. TXT ");
if(! In) cout<" Can 't open the file!" & lt; & lt; Endl;
Int I=0, x, n=0;
while(! In the eof ())
{
In the read ((char *) & amp; Stu [I], sizeof (stu [I])); i++; }
Do
{
Cout<" According to the student student id query - 1: "& lt; & lt; Endl<" According to the students name query - 2: "& lt; & lt; Endl;
Cout<" Please enter the need to query the way: ";
Cin> x;
If (x==1)
{
int m;
Cout<" Please enter a query of student's student id: ";
Cin> M;
for(int j=0; J<=I; J++)
If (stu [j]. Journal of num==m)
{
Cout<" Student: student id "& lt; & lt; Stu [I] num<& lt; Endl<" Student's name: "& lt; & lt; Stu [I] name<& lt; Endl<" Student achievement: "& lt; & lt; Stu [I] score<& lt; Endl;
N=1;
}
If (n==0) cout<" The student number to student information!" & lt; & lt; Endl;
}
The else
{
Char a, [10].
Cout<" The student's name: please enter a query"
Cin. The get ();
Cin. Getline (a, 10);
for(int j=0; J<=I; J++)
If (STRCMP (stu [j]. Name, a)==0)
{
Cout<" Student: student id "& lt; & lt; Stu [I] num<& lt; Endl<" Student's name: "& lt; & lt; Stu [I] name<& lt; Endl<" Student achievement: "& lt; & lt; Stu [I] score<& lt; Endl;
N=1;
}
If (n==0) cout<" Information without the students!" & lt; & lt; Endl;
}
Cout<" Whether or not to continue the query? Press 1, no press 0: ";
Cin> x;
} while (x==1);
in.close();
}
Void Xiugai ()
{
Ifstream in;
In the open (" stu. TXT ");
if(! In) cout<" Can 't open the file!" & lt; & lt; Endl;
Int I=0, x, n, c, j.
While (! In the eof ())
{
In the read ((char *) & amp; Stu [I], sizeof (stu [I]));
i++;
}
in.close();
Do
{
Cout<" Please enter the need to modify the student's student id: ";
Cin> x;
for(j=0; J<=I - 1; J++)
If (stu [j]. Journal of num==x)
{
Cout<" Student: student id "& lt; & lt; Stu [I] num<& lt; Endl<& lt;" Student's name: "& lt; & lt; Stu [I] name<& lt; Endl<" Student achievement: "& lt; & lt; Stu [I] score<& lt; Endl;
N=1;
Do
{
Cout<" Modify the student student number - 1: "& lt; & lt; Endl<" Modify the student's name - 2: "& lt; & lt; Endl<" Modify the student achievement - 3: "& lt; & lt; Endl<" Please enter the number of information needs to be modified, ";
Cin> c;
The switch (c)
{
Case 1:
Cout<" Please input the correct student id: ";
Cin> Stu [j]. Journal of num;
break;
Case 2:
Cout<" Please input the correct name: ";
Cin. The get (); Cin. Getline (stu [j]. Name, 10);
break;
Case 3:
Cout<" Please enter the correct grade: ";
Cin> Stu [j] score;
break;
}
Cout<& lt; Endl<" Whether to continue to modify the students information? Press 1, no press 0: "; Cin> c;
} while (c==1);
}
If (n==0) cout<" The student number to student information!" & lt; & lt; Endl;
Cout<& lt; Endl<" Whether to modify the students information? Press 1, no press 0: "; Cin> x;
} while (x==1);
Ofstream out;
Out. The open (" stu. TXT ", the ios: : out);
for(j=0; J<=I - 1; J++)
Out. Write ((char *) & amp; Stu [j], sizeof (stu [j]));
out.close();
}
Void Shanchu ()
{
Ifstream in;
Int n=1;
Do
{
In the open (" stu. TXT ");
if(! In) cout<" Can 't open the file!" & lt; & lt; Endl;
Int I=0, j, a, x;
while(! In the eof ())
{
In the read ((char *) & amp; Stu [I], sizeof (stu [I]));
i++;
}
in.close();
Cout<" Please enter the need to delete the student's student id: ";
Cin> x;
for(j=0; J<=I - 1; J++)
If (stu [j]. Journal of num==x) a=j;
Ofstream out;
Out. The open (" stu. TXT ", the ios: : out);
for(j=0; J<=a - 1; J++) out. Write ((char *) & amp; Stu [j], sizeof (stu [j]));
For (j=a + 1; J<=I - 1; J++) out. Write ((char *) & amp; Stu [j], sizeof (stu [j]));
out.close();
Cout<" Whether or not to continue to delete? Press 1, no press 0: ";
Cin> n;
} while (n==1);
}
Void main ()
{
Int k;
Do
{
Cout<" Input student information - 1 "& lt; & lt; Endl<" Browse the student information - 2 "& lt; & lt; Endl<" Query student information - 3 "& lt; & lt; Endl<" Modify the students information - 4 "& lt; & lt; Endl<" Delete student information - 5 "& lt; & lt; Endl<" Log out - 6 "& lt; & lt; Endl;
Cout<" Please enter the need to perform operation: ";
Cin> k;
The switch (k)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related