1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <stdio.h> typedef struct point { int x; int y; } POINT; POINT translate(POINT p, POINT delta); int main(void) { POINT p = { 2, 3 }; POINT delta = { 10, 10 }; POINT result; result = translate(p, delta); printf("(%d, %d)+(%d, %d)->(%d, %d)\n", p.x, p.y, delta.x, delta.y, result.x, result.y); return 0; } POINT translate(POINT p, POINT delta) { POINT new_p; new_p.x = p.x + delta.x; new_p.y = p.y + delta.y; return new_p; } | cs |