Why declare a struct that only contains an array in C?

Joe.Z picture Joe.Z · Aug 6, 2011 · Viewed 7.6k times · Source

I came across some code containing the following:

struct ABC {
    unsigned long array[MAX];
} abc;

When does it make sense to use a declaration like this?

Answer

Blagovest Buyukliev picture Blagovest Buyukliev · Aug 6, 2011

It allows you to pass the array to a function by value, or get it returned by value from a function.

Structs can be passed by value, unlike arrays which decay to a pointer in these contexts.