静态链表问题
p = p->next 改为p = p++为什么运行结果不正确,p += sizeof(a) 这样也不正确求解
#include <stdio.h>
struct weapon {
int price;
int atk;
struct weapon * next;
};
int main(){
struct weapon a,b,c,*head,*p;
a.price = 100;
a.atk = 100;
b.price = 200;
b.atk = 200;
c.price = 300;
c.atk = 300;
head = &a;
a.next = &b;
b.next = &c;
c.next = NULL;
p = head;
while(p != NULL){
printf("%d,%d\n",p->price,p->atk);
p = p->next;
}
}