Weird behavior of sizeof for arrays passed as parameters [duplicate]
问题 This question already has answers here : Using sizeof on arrays passed as parameters [duplicate] (4 answers) Closed 7 months ago . Can you explain this: void foo(const char data[10]) { char copy[10]; const char copy1[10] = {}; printf("%i", sizeof(copy)); //prints 10, as expected printf("%i", sizeof(copy1)); //prints 10, as expected printf("%i", sizeof(data)); //prints 4, WTF? } Looks like function parameters are treated as simple pointers for sizeof. But WHY does this happen? Is it documented