#includestruct student{long num;float score;struct student *next;};int main(){struct student a,b,*p;a.num=231231;b.num=311;b.score=2.0;a.score=1.0;a.next=&b;p=a->next; error:invalid type argument of '->' (have 'struct student')printf("%ld",p->num);re

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/30 11:02:26

#includestruct student{long num;float score;struct student *next;};int main(){struct student a,b,*p;a.num=231231;b.num=311;b.score=2.0;a.score=1.0;a.next=&b;p=a->next; error:invalid type argument of '->' (have 'struct student')printf("%ld",p->num);re
#include
struct student
{
long num;
float score;
struct student *next;
};
int main()
{struct student a,b,*p;
a.num=231231;
b.num=311;
b.score=2.0;
a.score=1.0;
a.next=&b;
p=a->next; error:invalid type argument of '->' (have 'struct student')
printf("%ld",p->num);
return 0;
}
如题,求教大神出错原因,为什么不能用->,我知道改成点可以通过编译

#includestruct student{long num;float score;struct student *next;};int main(){struct student a,b,*p;a.num=231231;b.num=311;b.score=2.0;a.score=1.0;a.next=&b;p=a->next; error:invalid type argument of '->' (have 'struct student')printf("%ld",p->num);re
指针才用->
如struct student a,*p;
对于a用点,对于p指针用->