// Simple example of a point struct. // CSE 374 demo #include // Declaring a new struct of type "struct Point" and // using typedef to simplify the name to "Point" typedef struct Point { int x; int y; } Point; // Forward declarations Point newPoint(); void translateX(Point* p, int deltaX); void print(Point* p); int main(int argc, char **argv) { Point p = newPoint(); print(&p); translateX(&p, 12); print(&p); } Point newPoint() { Point p; p.x = 0; p.y = 0; return p; } void translateX(Point* p, int deltaX) { p->x += deltaX; // OR // (*p).x += deltaX; } void print(Point* p) { printf("p = (%d, %d)\n", p->x, p->y); }