How do we get the number of elements in an array without using sizeof [duplicate]

When you use an array as an argument in a function call, it is automatically converted to a pointer to its first element. The C standard does not provide any means for finding the size of an array given only a pointer to its first element.

For a function to know the size of an array that is passed to it in this way, you must pass the size as a separate argument or must provide the function some other way of knowing the size, such as including a sentinel value to mark the end. (For example, the null character that marks the end of a string is a sentinel.)