Points with a struct
Points with a struct
A struct groups related values into one type. Here struct Point holds an x and a y. Complete two functions: make_point builds and returns a Point, and move_point shifts an existing one. With a pointer to a struct you reach its fields with ->, so p->x += dx moves it.
구조체와 포인트
struct은 관련된 값들을 하나의 타입으로 묶습니다. 여기서 struct Point은 x과 y을 포함합니다. 두 가지 함수를 완성하세요: make_point은 Point를 생성하고 반환하며, move_point은 기존 Point를 이동시킵니다. 구조체에 대한 포인터를 사용하면 ->으로 필드에 접근하므로, p->x += dx이 이를 이동시킵니다.
A struct Point with int x, y is given. Complete make_point(int x, int y) to build a Point, and move_point(struct Point *p, int dx, int dy) to shift it by (dx, dy) using ->.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.