My university professor gave us the following code but i feel like the 3rd row from the bottom should be
temp -> next = curr -> next -> next
If I am mistaken why is it correct ?
!!Note, the new node should be placed in the middle of the linked list and not in an edge!!
void insert_list (struct node *head, int pos) {
int k;
struct node *temp, *curr;
curr = ihead;
for (k=1; k<pos; k++)
curr = curr -> next;
temp = (struct node *) malloc (sizeof (struct node));
temp -> next = NULL;
gets (temp -> student);
scanf ("%d", &temp -> am);
temp -> next = curr -> next;
curr -> next = temp;
}