p221.8
1 #include<iostream> 2 #include<cstdlib> 3 #include<cstring> 4 using namespace std; 5 const int SLEN = 30; 6 struct student{ 7 char fullname[SLEN]; 8 char hobby[SLEN]; 9 int ooplevel; 10 }; 11 int getinfo(student pa[], int n); 12 void display1(student st); 13 void display2(const student *ps); 14 void display3(const student pa[], int n); 15 16 int main(){ 17 cout << "enter class size:"; 18 int class_size; 19 cin >> class_size; 20 while (cin.get() != ' ') 21 continue; 22 student *ptr_stu = new student[class_size]; 23 int entered = getinfo(ptr_stu, class_size); 24 for (int i = 0; i < entered; i++){ 25 display1(ptr_stu[i]); 26 display2(&ptr_stu[i]); 27 } 28 display3(ptr_stu, entered); 29 delete[]ptr_stu; 30 cout << "done "; 31 system("pause"); 32 return 0; 33 } 34 35 int getinfo(student pa[], int n){ 36 int i = 0, count = 0; 37 while (i < n && *pa[i].fullname != '