So I am writing a program that has a menu of choices that the user can choose from where they can insert, count, print, delete, and modify nodes. The user also has a 6th option to just quit the program. My issue is that whenever the user chooses 5th option, which is modify the student node, the program just abruptly ends instead of going back to the menu. Why is that and how can I fix this?
Here's the modify function that isn't working properly:
void modifyStudentNode()
{
int id = 0;
struct student *ptr, *prev, *currPtr;
if(start==NULL)
{
printf("\nStudent List does not contain data\n");
}
else
{
printf("\nPlease enter the student ID of the student whose records you wish to modify: \n");
scanf("%d",&id);
fflush(stdin);
for(currPtr = start; (currPtr)&&((currPtr->student_id)!= id); prev = currPtr, currPtr = currPtr->next);
if(currPtr == NULL)
printf("\nStudent not Found\n");
else
{
printf("\nCurrent values for Student Id %d are: ", id);
printf("Student Name: %s\n", currPtr->student_name);
printf("Student GPA: %.2f\n", currPtr->gpa);
printf("Student Date of Registration: %d/%d/%d\n\n", currPtr->dt_of_reg.month,currPtr->dt_of_reg.day,currPtr->dt_of_reg.year);
printf("\nEnter modified values for Student Id %d: \n", id);
printf("Enter Student's Modified Name:\n");
scanf("%[^\t\n]s",&currPtr->student_name);
fflush(stdin);
printf("Enter Student's Modified GPA:\n");
scanf("%f",&currPtr->gpa);
fflush(stdin);
printf("Enter Student's Modified Date of Registration (mm/dd/yyyy):\n");
scanf("%d/%d/%d", &currPtr->dt_of_reg.month,currPtr->dt_of_reg.day,currPtr->dt_of_reg.year);
fflush(stdin);
}
}
}