You copied the Doc URL to your clipboard.

Flexible array members in C99

In a struct with more than one member, the last member of the struct can have incomplete array type. Such a member is called a flexible array member of the struct.


When a struct has a flexible array member, the entire struct itself has incomplete type.

Flexible array members enable you to mimic dynamic type specification in C in the sense that you can defer the specification of the array size to runtime. For example:

extern const int n;
typedef struct
    int len;
    char p[];
} str;
void foo(void)
    size_t str_size = sizeof(str);  // equivalent to offsetoff(str, p)
    str *s = malloc(str_size + (sizeof(char) * n));