basically, im trying to get my program to print list of students with a specified year. for example, if the specified year = junior, then the program will print all the junior students in the list.
however, my program only prints out the first Junior student in list and stops afterwards. what is wrong with my function.
Heres the code for my function. Thanks in advance.
Code:
void printStudentsOfYear(STUDENTNODE* head, char * year)
{
// add your code
STUDENTNODE* currNode = head;
printf("-----DUMPING STUDENTS OF YEARS------\n");
while(currNode != NULL)
{
STUDENT* Student = currNode->student;
int cmp = strcmp(year,Student->year);
if (cmp == 0) {
printf("%s, %s, %d\n", Student->name, Student->ucinetid, Student->year, Student->studentid);
currNode = currNode->next;
}
}
}