![]() |
#2
lin51616782021-11-24 17:37
|

#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);
}
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);
}
只有本站会员才能查看附件,请 登录