#include <stdio.h>#include <stdlib.h>typedef struct weapon{ char name; int money; struct weapon *next;}lianbiao;int main(void){ lianbiao a,b,c,*head; lianbiao *p; a.name = '1'; a.money = 1; b.name = '2'; b.money = 2; c.name = '3'; c.money = 3; head = &a; a.next = &b; b.next = &c; c.next = NULL; p = head; while(p!=NULL)//调试的时候在这p变成了无效的地址 { printf("%s,%d\n",p->name,p->money); p->next; } system("pause"); return 0;}//我知道那里错了,输出单个字符用%c,p没有重新赋值导致循环一直不中止改为while(p!=NULL){printf("%c,%d\n",p->name,p->money);p = p->next;}就好了
目前暂无任何回答
- 0 回答
- 0 关注
- 1228 浏览
添加回答
举报
0/150
提交
取消