56. 구조체의 값 전달과 포인터 전달
다음 C 프로그램의 실행 결과를 쓰시오.
1#include <stdio.h>23struct Point {4int x;5int y;6};78void moveVal(struct Point p, int d) {9p.x += d;10p.y += d;11}1213void movePtr(struct Point *p, int d) {14p->x += d;15p->y -= d;16}1718struct Point mirror(struct Point p) {19int t = p.x;20p.x = p.y;21p.y = t;22return p;23}2425int main() {26struct Point a = {3, 8};27struct Point b = a;28moveVal(a, 5);29movePtr(&b, 2);30printf("%d %d / %d %d\n", a.x, a.y, b.x, b.y);31struct Point arr[2] = {a, b};32struct Point *q = arr;33for (int i = 0; i < 2; i++) {34movePtr(q + i, (i + 1) * 3);35}36a = mirror(arr[1]);37printf("%d %d / %d %d / %d\n", arr[0].x, arr[0].y, a.x, a.y, b.x);38return 0;39}