#include <stdlib.h>
#include<string.h>
#define NEW (struct node*)malloc(sizeof(struct node))
struct node
{
char name[20] ,tel[9];
struct node*next;
};
struct node *create()
{
struct node *h,*p,*q;
char name[20];
h=null;
printf("name: ");
gets(name);
while(strlen(name)!=0)
{
p=NEW;
if (p==NULL)
{
printf("Allocation failure\n");
exit(0);
}
strcpy(p->name,name);
printf("tel:");
gets(p->tel);
p->next=NULL;
if (h==NULL)
h=p;
else
q->next=p;
q=p;
printf("name: ");
gets(name);
}
return h;
}
main()
{
struct node*head;
head=create();
}
請問動態分配函數(struct node*)malloc(sizeof(struct node))前面的(struct node*)
是什麼意思?格式是怎樣的?
struct node *create()又是什麼函數?是返回struct node型結構體指針函數嗎?
還有這個程序無法運行。。。。請檢查一下,謝謝!!!