i have the following code:

Code:

testNode *temp = current;
testNode *loc;
loc = current->next;
current->next = current->next->next;
loc->next = current;
current = loc;

which swaps 2 nodes around (the first node be at the start of the list)

now i'm having trouble understanding how it works.

if we have the following:

BA and we want AB

Code:

loc = start->next; // we save **A** to *loc*
current->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

any ideas?

i just want to understand how it works.