我最近注意到
void foo(int array[10]);
调用foo
时不会将数组的内容加载到堆栈中,因此声明等同于:
void foo(int *array):
我想在 C99 标准中找到断言此行为的部分,但我没有找到任何内容,或者我不知道应该搜索什么。到目前为止,我尝试了by reference
、by value
、function call
、passing arguments
、...
最佳答案
C11 6.7.6.3 §7。 (C99 6.7.5.3 §7)
A declaration of a parameter as ‘‘array of type’’ shall be adjusted to ‘‘qualified pointer to type’’, where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation.
该术语正式命名为“数组调整”。在 C 标准之外,它通常被非正式地称为“数组衰减”。
关于c - C99 中的哪一节说数组在 C 中没有复制地传递给函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49515956/