deleting a Linked list

ok so i have my linked list..created from a struct with my node * next_ptr.

So now how do i delete a whole linked list? not the head node alone, or a node somewhere in the middle..or the last..but the head and everything it contains..i don't want to be empyting them one by one..i know how to do there not one command which eliminates everything in a single go?

By definition, a linked list requires you to iterate over it to perform operations, so no. If you could guarantee that all of the nodes were stored in a contiguous block of memory, then you could delete the contents of the entire block, but that would pretty much defeat the purpose of using a linked list in the first place
so it means to empty the the list i have to delete all the middle nodes till i get two nodes then i delete the last one and delete the head..okkkk..
fair taking the challenge to do that
Topic archived. No new replies allowed.