I saw next code in the project I work:
struct Str
{
size_t count;
T data[1];
};
Str* str = (Str*)malloc(sizeof(Str) + sizeof(T) * count);
str->count = count
...
str->data
is used as an array with count
elements of T
from this point.
Why one would declare T data[1]
instead of T* data
? Is there any benefit of doing this?