I'm learning the C Language.
I need the size of the int array(passed in the parameter of a function).
I'm able to get the size of int array that using:
int size = sizeof(arr) / sizeof(int);
But, When I'm using the same code on parameterized array, the above piece of code is not working for me.
Program:
void printArraySize(){
int arr[]= {1, 2, 3, 4, 6, 7};
int size = sizeof(arr) / sizeof(int);
printf("\nSize = %d",size); // resulting right value
doStuff(arr);
}
void doStuff(int arr[]){
int size = sizeof(arr) / sizeof(int); // resulting 1
printf("\ndoStuff::Size = %d",size);
}
Output:
Size = 6
doStuff::Size = 1
The "size" value is displaying right. But, why doStuff::Size is 1 ?
Although, I'm using the same concept in both the functions the difference is only the parameterized array.
Please give your suggestions or correct the mistake if I've done any.