You might could do it like this:
QueueNode* deQueue(TQueue* q){
QueueNode *tmp = q->last;
while(tmp->next != q->first) {
tmp = tmp->next;
}
// new first is now the old second element
q->first = tmp;
// new firsts' next still points at
// old first so we free that memory here
free(q->first->next);
q->first->next = NULL;
return tmp;
}
Don't forget to free your memory.
You can test it here: http://www.compileonline.com/compile_c_online.php