代码在编译时给了我错误,我不知道为什么这个问题是关于一家政策公司的,但它在这里没有任何关系,只是为了让你了解我想要做什么
我认为错误在“(* h)= temp”行中
typedef struct
{
char cmp_name[20];
int pol_code;
float pol_price;
int drivers;
float new_d;
float old_d;
} POL;
typedef struct node
{
POL policy;
struct node *next;
} NODE;
void ins(NODE **h,NODE *p)
{
NODE *temp;
temp=(NODE*)malloc(sizeof(NODE));
if(p==NULL)
{
(*h)=temp;
temp->next=NULL;
}
else
{
p->next=temp;
p=p->next;
temp->next=NULL;
}
printf("\nEnter Company Name: ");
scanf("%s",temp->policy.cmp_name);
printf("\nEnter Policy Code: ");
scanf("%d",temp->policy.pol_code);
printf("\nEnter Policy Price: ");
scanf("%f",temp->policy.pol_price);
printf("\nEnter Number of Drivers: ");
scanf("%d",temp->policy.drivers);
printf("\nAddon for a New Driver: ");
scanf("%f",temp->policy.new_d);
printf("\nAddon for a Old Driver: ");
scanf("%f",temp->policy.old_d);
}