} while (tmp != NULL);
This won't work because tmp will become null, which will exit us from the loop.
I need tmp->next later in the code, therefore I need the last non-null value of tmp.
} while (tmp != NULL);
This won't work because tmp will become null, which will exit us from the loop.
I need tmp->next later in the code, therefore I need the last non-null value of tmp.