简体   繁体   English

函数定义中的指针与数组:void fct1(int * p)和void fct1(int p [])之间的区别是什么?

[英]Pointer vs Array in function definition: what is the difference between void fct1(int *p) and void fct1(int p[])?

i wanna know what is the difference between 我想知道它们之间有什么区别

void fct1(int *p)

and

void fct1(int p[]) 

i know that both are pointers but are there any differences 我知道这两个都是指针,但有任何差异

There is absolutely no difference when used as a function parameter like that. 当用作这样的函数参数时绝对没有区别。 The compiler treats both forms identically. 编译器以相同的方式处理两种形式。

There is no difference. 没有区别。 For completeness, here's what the standard says: 为了完整起见,这是标准所说的:

C99 standard 6.7.5.3 section 7 C99标准6.7.5.3第7节

A declaration of a parameter as ''array of type '' shall be adjusted to ''qualified pointer to type '', ... 参数声明为''数组类型 ''应调整为''限定指向类型 '',...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 这个表达式是什么:void *(* fct)(void *(*)(void *),void *)? - What does this expression: void* (*fct)(void*(*)(void*), void*)? int (*cmp)(void) 和 int *cmp(void) 有什么区别? - What is the difference between int (*cmp)(void) and int *cmp(void)? 回调函数:void(* func)(int)和void(func)(int)之间的区别 - callback function: difference between void(*func)(int) and void(func)(int) "int *p =0;" 和有什么不一样和“int *p;*p=0;” - What is the difference between "int *p =0;" and "int *p; *p=0;" void function 和 int *function for return arrays 有什么区别 - What is the difference between void function and int *function for returning arrays int *p[5]和通过malloc得到的指针有什么区别? - What is the difference between int *p[5] and a pointer obtained through malloc? 将 int 转换为指针 - 为什么先转换为 long? (如 p = (void*) 42; ) - Cast int to pointer - why cast to long first? (as in p = (void*) 42; ) 在数组上下文中,int * p和int(* p)[]有什么区别? - What is the difference between int* p and int (*p)[] in the context of arrays.? (int *)p和&p之间的区别 - Difference between (int *)p and &p `int *p` 和 `int (*p)[3]` 之间的区别? - Difference between `int *p` and `int (*p)[3]`?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM