Untitled
unknown
plain_text
a year ago
896 B
9
Indexable
struct Student *find_student_by_id(struct Student students[], int numStudents, const char *studentID, const char *className) {
char normalizedInputID[11];
strcpy(normalizedInputID, studentID);
normalizeID(normalizedInputID);
char normalizedInputClassName[50];
strcpy(normalizedInputClassName, className);
normalizeID(normalizedInputClassName);
for (int i = 0; i < numStudents; i++) {
char normalizedFileID[11];
strcpy(normalizedFileID, students[i].studentID);
normalizeID(normalizedFileID);
char normalizedFileClassName[50];
strcpy(normalizedFileClassName, students[i].className);
normalizeID(normalizedFileClassName);
if (strcmp(normalizedFileID, normalizedInputID) == 0 && strcmp(normalizedFileClassName, normalizedInputClassName) == 0) {
return &students[i];
}
}
return NULL;
}Editor is loading...
Leave a Comment