大神帮忙看看哪出问题了,结构指针.谢谢
大神帮忙看下这个代码哪里有问题,出现error程序代码:
#include<stdio.h> struct point{ int x; int y; }; struct point* getStrcut(struct point*); void output(struct point); void print(const struct point *p); int main(int argc,char const *argv[]) { struct point y={0,0}; getStruct(&y); output(y); output(*getStruct(&y)); print(getStruct(&y)); getStruct(&y)->x = 0; *getStruct(&y) = (struct point){1,2}; } struct point* getStruct(struct point *p) { scanf("%d",&p->x); scanf("%d",&p->y); printf("%d,%d",p->x,p->y); return p; } void output(struct point p) { printf("%d,%d",p.x,p.y); } void print(const struct point *p) { printf("%d,%d",p->x,p->y); }