data-structures · beginner · ~15 min
Aggregate over a typedef'd struct's fields.
Define typedef struct { int x, y, z; } Vec3; and implement long dot(Vec3 a, Vec3 b) returning a.xb.x + a.yb.y + a.z*b.z.
typedef struct { int x, y, z; } Vec3;
long dot(Vec3 a, Vec3 b) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.