Values & References10 / 18
Up next

Borrow a big struct

#include <stdio.h>

typedef struct {
    int data[256];
} Big;

long sum(const Big *b) {
    long total = 0;
    for (size_t i = 0; i < 256; i++) {
        total += b->data[i];
    }
    return total;
}

int main(void) {
    Big b = {0};
    b.data[0] = 42;
    printf("%ld\n", sum(&b));
    return 0;
}
What you're solving

pass a const pointer to avoid the copy