Home > Back-end >  Beginners start learning c this code appears the wrong but can't find the cause of the error ha
Beginners start learning c this code appears the wrong but can't find the cause of the error ha

Time:11-13

#include
using namespace std;
#include
#include
#include
#include




Struct Student {
string name;
Int score;
};

Struct the Teacher {
string name;
Student s_arr [5].
};

Void allocatespace (the Teacher t_arr [], int len) {
String t_name="teacher";
String s_name="students";
String nameseed [5]={" A ", "B", "C", "D", "E"};

for (int i=0; iT_arr [I]. Name=t_name + nameseed [I];

For (int j=0; j<5; J++) {
T_arr [I] s_arr [j]. Name=s_name + nameseed [j];
Int the random=rand () % 61 + 40;
T_arr [I] s_arr [j]. Score=random;
}
}
}

Void print (the Teacher t_arr [], int len) {
for(int i=0; i cout <"Teacher's name:" & lt; For (int j=0; j <5; J++) {
cout <& lt;" Student's name: "& lt; }
}
}

Int main () {


Srand ((unsigned int) time (NULL));
The Teacher t_arr [3].
Int len=sizeof (t_arr)/sizeof (t_arr [0]).

Allocatespace (struct the Teacher t_arr [3], len);

Print (struct the Teacher t_arr [3], int len);

return 0;
}

CodePudding user response:

 
Allocatespace (struct the Teacher t_arr [3], len);//to allocatespace (t_arr, len); Downward similar

Print (struct the Teacher t_arr [3], int len);

  • Related