A construction with empty brackets [] allowed as the last element of a struct . It allows you to allocate additional space outside the sizeof(sdshdr) for array elements, allowing you to insert array data with the array itself.
Pointers, on the other hand, store data in a separately managed memory segment and require an additional free call at the end. Unlike the [] method, pointers allow you to have more than one array of variable length inside the same struct , and this element can be placed anywhere in the struct , and not just at the end of the struct .
source share