Hi,
I am trying to sort a student database by age,but i am not sure whats wrong i think it has to deal with tmpstudent variable.
Code:void insertion_sort(StudentDB *db) { int i; for (i = 0; i < db->num; ++i) { int j = i - 1; int val = db->records[i].age; Student *tmpStudent = &db->records[i]; while (j >= 0 && val < db->records[j].age) { db->records[j + 1] = db->records[j]; j--; } db->records[j + 1] = *tmpStudent; } }