Since you can only pass a pointer to an array - and not the array itself - as an argument to a function in C, the information regarding the length of the array is lost. While you can derrive the length with something like sizeof(arr) / sizeof(int)
, that is a run-time operation and quite ugly.
There are other data structures, such as std::vector, that solves this problem, but it comes with a lot of other aspects, such as dynamic memory allocation, that you might not be interested in.
This gist provides a super simple implementation of an array of a fixed size that is not dynamically allocated but has its length as a property. Just like a normal array, it allows indexed element read and write operations, but nothing more.