042-struct-fn-arg.c (381B)
1 // tests/cc-parse/42-struct-fn-arg.c — struct passed by pointer to a 2 // function. Smoke-tests struct primitives: caller takes &s, callee 3 // dereferences via -> on the pointer arg. 4 // 5 // sum2(&s) where s={3,5} returns 8. 6 7 struct P { int x; int y; }; 8 9 int sum2(struct P *p) { 10 return p->x + p->y; 11 } 12 13 int main() { 14 struct P s; 15 s.x = 3; 16 s.y = 5; 17 return sum2(&s); 18 }