// Ex662.cc // Sec. 6.6 of lecture // Referenz and dynamical array of type student // Input: a.out < input.650 #include main() { struct Student { long long int matrikel; int skz; char name[30], vorname[20]; }; int i, n; Student *gruppe; // pointer at Student cout << endl; cout << " How many Students : "; cin >> n; // input n gruppe = new Student[n]; // allocate memory // Data input; for (i = 0; i < n; i++) { cout << endl << "Student nr. " << i << endl; cout << "Familenname : "; cin >> gruppe[i].name; cout << "Vorname : "; cin >> (gruppe+i)->vorname; cout << "Matrikelnummer : "; cin >> gruppe[i].matrikel; cout << "SKZ : "; cin >> gruppe[i].skz; } cout << endl; i = 3; if ( i < n) { // reference on comp. of structure int &rskz = gruppe[i].skz; // reference on structure Student &rg = gruppe[i]; // reference on comp. of referenced structure long long int &rm = rg.matrikel; cout << endl; cout << "Student nr. " << i << " : "; cout << rg.vorname << " " << rg.name << " , "; cout << rm << " , " << rskz << endl; } delete [] gruppe; // deallocate memory }