回复 8楼 azzbcc
改了!不过输出不对啊 输出NULL
struct student stru[4] = {{"wang",24},{"wwe",27},{"wll",30},{"yyf",34}};这里把它初始化为结构体数组
struct student { char name[10]; int age; struct student *next; };并没有给next任何地址,而是只有调用它
while(p != NULL) { array[i] = (p->age)-age; p = p->next; if(array[i]<0) array[i] = 0 -array[i]; i++; }所以这个循环只会一次,或者说是错误的,因为next都没有初始化