Skip to content · ⁨Bỏ qua nội dung⁩

Points with a struct · ⁨Điểm với struct⁩

English

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.

Tiếng Việt

Con trỏ với struct

Một struct nhóm các giá trị liên quan vào một kiểu dữ liệu. Ở đây struct Point chứa một x và một y. Hoàn thành hai hàm: make_point tạo và trả về một Point, và move_point dịch chuyển một điểm đã tồn tại. Với con trỏ đến struct, bạn truy cập các trường của nó bằng ->, do đó p->x += dx di chuyển nó.

Log in or create account · ⁨Đăng nhập hoặc tạo tài khoản⁩

IGCSE, A-Level & AP