c语言结构体怎么编译,C语言结构体,我用点不行,必须要用->才编译成功,这是为什么...

#include

#include

#include

#define LEN sizeof(struct student)

struct student

{

int number;

struct student *pnext;

};

int n;

struct student *creat(void)

{

struct student *head,*p1,*p2;

n=0;

p1=p2=(struct student *)malloc(LEN);

head=NULL;

scanf("%d",&p1.number);

while(p1.number!=0)

{

n++;

if(n==1) head=p1;

else p2->pnext=p1;

p2=p1;

p1=(struct student *)malloc(LEN);

scanf("%d",&p1.number);

}

p2->pnext=NULL;

return(head);

}

main()

{

struct student *p;

p=creat();

while(p->pnext!=NULL)

{

printf("%d\n",p->number);

p=p->pnext;

}

return 0;

}

17 17 E:\学习\C源程序\C红书刷题\第三章_结构数据\链表\创建动态链表\未命名2.cpp [Error] request for member 'number' in 'p1', which is of pointer type 'student*' (maybe you meant to use '->' ?)

这是错误提示,然后我把.改成了->就解决了。为什么要这样, 点和->作用不是一样的么

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值