结构体应用#2 结构体指针
#include <stdio.h>
#include <stdbool.h>
struct point
{
int x;
int y;
};
struct point* getStruct(struct point*);
void output(struct point p);
void structPrint(const struct point *p);
int main()
{
struct point y = {0, 0};
output(y);
output(*getStruct(&y));
//or structPrint(getStruct(&y));
return 0;
}
struct point* getStruct(struct point *p)
{
scanf("%d", &p->x);
scanf("%d", &p->y);
return p;
}
void output(struct point p)
{
printf("output:%d,%d\n", p.x, p.y);
}
void structPrint(const struct point *p)
{
printf("structPrint:%d,%d\n", p->x, p->y);
}