Hi all,
is it correct, that an array as functional parameter degrades to a pointer?
Example:
#include <stdio.h>
typedef char test_t[200];
void func(test_t t)
{
printf("%d", sizeof(t)); // returns 4 instead of 200
}
int main(int argc, char *argv[])
{
test_t t;
func(t);
return 0;
}
Regards,
Andreas
A quick look at the assembly code in the debugger shows the answer. The code is identical whether or not you use & on the structure.
Yes, the array will degrade to a pointer so the sizeof operator will give the size of a pointer. If you need the size of the array you have to pass that as well.
John