A pointer in C is just an address. When used as an array, you have to figure out (by some other means) the length of the array.
A lot of libraries dealing with arrays have functions accepting both the pointer to the array and its size. For example qsort(3) wants a second nmemb
argument giving the number of elements of the array base
(first argument to qsort
) to be sorted.
Alternatively, instead of passing just a pointer, you could use flexible array members (in C99) and pass (and return, when relevant) a pointer to a structure like
struct eph_tuple_st {
unsigned len;
eph_t* ptrtab[];
};
with the convention that the flexible array ptrtab
field has len
elements.
At last, as others suggested, you could use a sentinel value (i.e. a null word) to end the array. Generally I don't recommend that (risk of buffer overflow, time complexity to compute the actual size).
FWIW, recent C++ have std::dynarray (C++2014) and std::vector, and Ocaml has the Array module. You could switch to some more friendly programming language.