You cannot return an array from C. You can only return one instance of the same data type.
This data type may be a pointer to memory storing a sequential list of numbers (or something else), but you lose all the information about how long the result is, so you either need to know this, or you should have a different value as output variable to indicate the length.
You can also return your own data type, for example, struct, which will contain both a list of data and a length. However, returning a large data structure creates several small copies of the data structure, slowing down your program and also creating memory nightmares with leaks and multiple links.
Reverting a pointer to a custom data structure, however, may work very well.
source share