Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 570
user2142328 Avatar asked Mar 07 '13 01:03

user2142328


2 Answers

There is absolutely no difference when used as a function parameter like that. The compiler treats both forms identically.

like image 140
Mark Ransom Avatar answered Oct 14 '22 04:10

Mark Ransom


There is no difference. For completeness, here's what the standard says:

C99 standard 6.7.5.3 section 7

A declaration of a parameter as ‘‘array of type’’ shall be adjusted to ‘‘qualified pointer to type’’, ...

like image 2
newacct Avatar answered Oct 14 '22 04:10

newacct