This code does not
wont work, you can't
compile this code (feel the difference

).
struct node *-next; /* Why minus sign? */
Well, you declare n as an alias of
struct node type. Why?
These function works with declared elsewhere global variables. Why?
ptr=n*(malloc(sizeof(n));
ptr=head;
Let's forget for a minute that n is a structure type, not a number. The 1st statement allocates memory and saves a pointer to the new object in ptr pointer variable. The next statement overwrites this value immediately. Why?
And so on...
It seems you must reread your C textbook right now...
Reputation Points: 1234
Solved Threads: 347
Postaholic
Offline 2,001 posts
since Jul 2008