Points with a struct · Points avec un 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.
Points avec une structure
Un struct regroupe des valeurs liées en un seul type. Ici struct Point contient un x et un y. Complétez deux fonctions : make_point construit et retourne un Point, et move_point déplace un existant. Avec un pointeur vers une structure, vous accédez à ses champs avec ->, donc p->x += dx le déplace.
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 ->. · Un struct Point avec int x, y est donné. Complétez make_point(int x, int y) pour construire un Point, et move_point(struct Point *p, int dx, int dy) pour le déplacer de (dx, dy) en utilisant ->.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.