#include #include #define MAX 5 main() { typedef struct StudentRecord { char student_no[8]; char name[20]; } StudRec; StudRec students[MAX]; int i; char s[20]; for (i = 0; i < MAX; i++) { cout << "Student " << i << ":\n"; cout << "Student Number: "; cin.getline(students[i].student_no, 8); // The above statement reads a string // of maximum length 8 into the variable // students[i].student_no. cout << "Name: "; cin.getline(students[i].name, 20); } for (i = 0; i < MAX; i++) { strncpy(s, students[i].name, 4); s[4] = '\0'; if (strcmp(s, "Chan") == 0) cout << students[i].name << endl; } return 0; }