dynamic arrays and flexible arrays

598 Views Asked by At

what is the difference between those two types of arrays, thanks in advance for any good example taken from different languages

2

There are 2 best solutions below

0
On BEST ANSWER

In C/C++ a flexible array is a member of a struct that is an array (not just a pointer) but doesn't specify a length (reference). As such, a struct with a flexible array is an incomplete type, so the typeof operator can't be used.

A dynamic array is an ordered collection (list) that can grow and shrink. Dynamic arrays are usually implemented as a linked list or something similar.

0
On

Dynamic arrays have values that can be changed by code and more values populated. The flexible array is an array that does not have a hard coded limit to its length.