One additional note about:
Code:
head=NewNode(&head);
The reason I made the function return a pointer to the new head was to allow you to still take care of the list on an allocation failure. The way your call works, if the new node allocation fails, you end up setting head to NULL in the calling function and there's no way to continue gracefully. It's the same reason it's suggested to use a temporary pointer while using realloc(). e.g.:
Code:
tmp = realloc(oldchunk, newsize);
if(tmp == NULL)
// You can continue playing with oldchunk even though realloc() failed
else
oldchunk = tmp;
vs.
Code:
oldchunk = realloc(oldchunk, newsize);
if(oldchunk == NULL)
// Screwed because you just lost your pointer to oldchunk