5 ms·
Additionally, here is a thread of Linus Torvalds pointing out even more of the confusing nature of arrays and sizeof in C: I really like the idiom for passing
by ucs 10y ago
Additionally, here is a thread of Linus Torvalds pointing out even more of the confusing nature of arrays and sizeof in C:
I really like the idiom for passing sized arrays suggested at the end of that LKML thread[1]: pass them by reference!
void func(int (*arr)[256])
{
printf("arr size: %ld\n", sizeof(*arr));
}
int main(void)
{
int array[256];
func(&array);
}
[1] https://lkml.org/lkml/2015/9/7/147 https://lkml.org/lkml/2015/9/7/147