c - What is the difference between foo(int arr[]) and foo(int arr[10])? -
is there difference between 2 function in c?
void f1(int arr[]) { //some code... } void f2(int arr[10]) { //some code }
what size of first array in f1 function?
is there difference between 2 function in c?
no difference here. both interpreted int *arr
compiler arrays converted pointer first element when used function parameter.
what size of first array in f1 function?
strictly speaking, there no array here. pointer int
. if use sizeof(arr)
, value equal sizeof(int *)
.
the array size in parameters needed when type of parameter pointer array. in case need have specify size of array each size makes pointer point different type.
void f3(int (*arr)[10]); // expects pointer array of 10 int
Comments
Post a Comment