错哪了,各位前辈
/* Note:Your choice is C IDE */
#include "stdio.h"
#include<malloc.h>
struct weapon{
int atk;
int price;
struct weapon * next;
}
struct weapon*create()//空格不是问题
{
int a=0;
struct weapon *p1,*p2,*head;
p1=p2=(struct weapon*)malloc(sizeof(struct weapon));
scanf("%d%d",&p1->atk,&p1->price);
while(p1->atk!=0)
{
a++;
if(a==1)//==
head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct weapon*)malloc(sizeof(struct weapon));
scanf("%d%d",&p1->atk,&p1->price);//指针用->
}
p2->next=NULL;
return (head);
}
void main()
{
struct weapon *p;
p=create();
printf("%d%d",p->atk,p->price);
}