This code takes input from user and simply stores them in an array.The array is then passed to a function and then printed out.The problem is that when I check the size of array in main() and then in function() they are different.Please check the output image link I provided to clearly understand what I am saying. The size of int is 4 bytes. Dev-C++ is IDE used which uses TDM-GCC 4.9.2 64 bit compiler.Can someone clarify what is going on here?
#include<stdio.h>
int function(int formal[]);
main()
{
int input[10],loop,limit;
printf("Enter limit:");
scanf("%d",&limit);
for(loop=0;loop<limit;loop++)
{
scanf("%d",&input[loop]);
}
printf("Size of input array:%d\t",sizeof(input));
function(input);
}
int function(int formal[])
{
int loop;
printf("Size of parameter array:%d\n",sizeof(formal));
for(loop=0;loop<5;loop++)
{
printf("%d\n",formal[loop]);
}
}
output: [1]: https://i.stack.imgur.com/LqHiS.png