Do they always pass in the size as a parameter, e.g.
void lame_function (int * arr, int n)
{
// .. do something
}
or is there a trick to make the compiler run sizeof(arr)
inside the function in the same way that it would run it outside the function?
I already tried making the signature
void lame_attempt (int ** arr, int n)
{
// ... use sizeof(*arr);
}
and trying to use it like
int myArray [] = {1, 50, 39, 22};
lame_attempt ( &myArray );
but that didn't work.
There has to be a way, because what if I'm a member of a religion that prohibits writing functions with more than 1 parameter?
Do some C programmers make a struct like
typedef struct realArray { int * ptr0; int len; } realArray;
and use that throughout their program?