#include <stdio.h>
struct point {
int x;
int y;
};
struct point* getStruct(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)); //*拿出右侧地址(getStruct(&y))的值
print(getStruct(&y));
*getStruct = (struct point){1,2};
return 0;
}
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->y,p->y);
}
有点晕眩。。。。