为什么在结构体里加个char 成员不行呢
1 #include <stdio.h>
2
3 typedef struct weapon{
4 char name[10];
5 int price;
6 int atk;
7 struct weapon * next;
8 } weapon_t;
9
10 int main(){
11 weapon_t a,b,c, * head, * p;
12 a.name="qq";
13 a.price=100;
14 a.atk=200;
15 b.name="qq1";
16 b.price=300;
17 b.atk=400;
18 c.name="qq2";
19 c.price=500;
20 c.atk=600;
21 head=&a;
22 a.next=&b;
23 b.next=&c;
24 c.next=NULL;
25
26 p=head;
27 while(p!=NULL){
28 printf(" %d %d\n",p->price,p->atk);
29 p=p->next;
30 }
31 return 0;
数组赋值不能这样来的吧,要用strcpy吧