i have the following code:

which swaps 2 nodes around (the first node be at the start of the list)Code:testNode *temp = current; testNode *loc; loc = current->next; current->next = current->next->next; loc->next = current; current = loc;

now i'm having trouble understanding how it works.

if we have the following:

BA and we want AB

any ideas?Code:loc = start->next; // we saveAtoloccurrent->next = current->next->next; <--- i don't understand this bit! Since nothing // exists after current, next, next. Does it just make the two nodes point together? loc->next = current; // we put B after A current = loc; // put A before B

i just want to understand how it works.