Hi , there was a question asked in one of the interviews.. Delete all the nodes of link list..Let me know if I have written the correct code
Code:
struct node 
{int data'
struct node *next;};
typedef struct node NODE;
NODE head;

void deleteall(){

NODE *ptr;
ptr=head;
while (head!=NULL)
{ptr=head;
head=head->next;
free(ptr);
}



}
Here free just de allocates the memory, so I don't have to define ptr in the loop. Let me know if I am wrong.