I've seen in the ISO C99 committee draft that structs can have an incomplete an array with unspecified size its end, known as Flexible Array Member.
On the other hand C99 also has Variable Length Arrays, which allow declaring arrays with size not constant at compile-time.
I thought that a FAM was a special kind of a VLA, but I've seen two SO users claiming otherwise. Also, reading the Wikipedia section on sizeof
, it says that sizeof
behaves differently for those two.
Why do both of them exist instead of just one? (Are their use-cases too different?)
Also, which other associated behaviors are different for each of them?
sizeof
. The size of a VLA is a run-time computed value — unlike all other occurrences ofsizeof
. The size of a structure containing a FAM is fixed at compile time and does not include the size of the FAM. – Mannie