P
pemo
In c99 we can write this:
void func(int size, double arr[*size*])
{
return;
}
int main(void)
{
double arr[10] = {0.0};
func(sizeof(arr) / sizeof(double), arr);
return 0;
}
The question is, in func(), does using arr[size] serve any purpose apart
from being semantically useful - regarding the size of arr [semantially, we
can say that the int size parameter *encodes* the size of arr and is in fact
not some other unrelated info], and/or, possibly helping the compiler
optimise the code - and if the latter, in what ways might this be done?
void func(int size, double arr[*size*])
{
return;
}
int main(void)
{
double arr[10] = {0.0};
func(sizeof(arr) / sizeof(double), arr);
return 0;
}
The question is, in func(), does using arr[size] serve any purpose apart
from being semantically useful - regarding the size of arr [semantially, we
can say that the int size parameter *encodes* the size of arr and is in fact
not some other unrelated info], and/or, possibly helping the compiler
optimise the code - and if the latter, in what ways might this be done?