Points with a struct · Pontos com 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.
Pontos com struct
Um struct agrupa valores relacionados em um único tipo. Aqui struct Point armazena um x e um y. Complete duas funções: make_point constrói e retorna um Point, e move_point desloca um existente. Com um ponteiro para um struct, você acessa seus campos com ->, então p->x += dx o move.
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 ->. · Um struct Point com int x, y é fornecido. Complete make_point(int x, int y) para construir um Point e move_point(struct Point *p, int dx, int dy) para deslocá-lo por (dx, dy) usando ->.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.