Code the following trouble help me find the bug
# include
# include
# include
using namespace std;
//int n=0;
Struct Worker {
int num;
char name[20];
int age;
Float wage;
};
Void input (int n, Worker * w) {
for(int i=0; i
Cin> W [I] num;
Cout<& lt;" Name: ";
Cin> W [I]. Name;
Cout<& lt;" Age: ";
Cin> W [I] the age;
Cout<& lt;" Wage: ";
Cin> W [I]. Wage;
}
}
Void bubble_sort (int n, Worker * w) {//sorting
The Worker w1.
Bool change=true;
For (int I=n - 1; I>=1 & amp; & Change==true; I -) {
Change=false;
for(int j=0; JIf (w [j] num> W [j + 1] {num)
W1=w [j];
[j]=w w [j + 1);
W [j + 1)=w1;
Change=true;
}
}
}
}
Void write_file (char * filename, int n, Worker * w) {
Fstream outfile (filename, the ios: : out | ios: : binary);
if(! Outfile) {
Cerr<& lt;" Open the file error!"
}
//outfile. Write (sizeof (char *) w, [I] (w));
for(int i=0; i
//cout}
Outfile. Close ();
}
Void show (int n, Worker * w) {
for(int i=0; i
}
Void read_file (char * filename, int n, Worker * w) {
Fstream infile (filename, the ios: : | in ios: : binary);
if(! Infile) {
Cout<& lt;" The open ifle error!"
}
//Worker * w2=new Worker [n].
//ifile. Read (w2 (char *), sizeof (w2));
for(int i=0; i
Cout<& lt;" Num: "& lt;
Infile. Close ();
}
The Worker * add (int & amp; Num, Worker * w) {
Int num1.
If (w==NULL | | num==0) {
Cout<& lt;" You have not creat a list!"
}
Cout<& lt;" Both please input number of extra workers: ";
Cin> Num1.
The Worker * w1=new Worker [num + num1];
for(int i=0; i
}
If (i>=num& & i
Cin> W1 [I] num;
Cout<& lt;" Name: ";
Cin> W1 [I]. Name;
Cout<& lt;" Age: ";
Cin> W1 [I] the age;
Cout<& lt;" Wage: ";
Cin> W1 [I]. Wage;
}
}
Num +=num1;
Return w1.
}
Int the select (char * filename, int n, Worker * w) {
Cout<& lt;" Both please input the worker num: ";
Int num1.
Cin> Num1.
If (num1==0) {
return 0;
}
Fstream infile (filename, the ios: : | in ios: : binary);
if(! Infile) {
Cout<& lt;" The open error!"
}
int i;
for(i=0; i
If (num1==w [I] num) {
Cout<& lt;" Num: "& lt;
}
}
If (I==n) {
Cout<& lt;" No this person "& lt;
return 0;
}
Int main () {
int n=0;
Int num=0;
The Worker * w=NULL;
Cout<& lt;" Worker_system "& lt;
Cout<& lt;" Do your choice: ";
Cin> n;
{if (n==6)
break;
}
The switch (n) {
Case 1:
//cout
Cout<& lt;" Do the import number of worker: ";
Cin> Num.
W=new Worker (num);
Input (num, w);
Write_file (" worker_sys. TXT ", num, w);
break;
}
The else {
Cout<& lt;" Already creat a list!"
}
Case 2:
W=add (num, w);
//cout
//cout<1
Case 3:
If (num==0) {
//bubble_sort (num, w); break;
Cout<& lt;" You have not creat a list!"
}
The else {
Bubble_sort (num, w);
break;
}
Case 4:
If (num==0) {
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull