42 Exam 05 May 2026

Trust your muscle memory from the Piscine. Trust your while loops. Free your memory.

void ft_list_sort(t_list **begin_list, int (*cmp)()) !*begin_list) return; swapped = 1; while (swapped) 42 exam 05

When you sit down for Exam 05, remember this: Every peer in your cluster has memorized the exact same man pages. The only difference between a pass and a fail is breathing, planning, and refusing to panic when your first gcc command returns a wall of errors. Trust your muscle memory from the Piscine

swapped = 0; current = *begin_list; while (current && current->next) if ((*cmp)(current->data, current->next->data) > 0) temp = current->data; current->data = current->next->data; current->next->data = temp; swapped = 1; current = current->next; void ft_list_sort(t_list **begin_list, int (*cmp)())

if (!begin_list || !*begin_list) return ; You need a temporary pointer to swap node contents. However, swapping data is easier than swapping next pointers. (Note: In 42 exam 05, swapping data is allowed because the subject doesn't forbid it. Swapping pointers is for purists.)


42 exam 05
© 2025

Back to Top