When an array is passed as an argument , the compiler generates a pointer to the array's first element and that pointer is passed to the function rather than the full array, so my question is why we can print the values of the array when we print array[i]
?
void FunctionApi(int array[])
{
int i;
for(i=0;i<8;i++)
{
printf("Value =%d\n",array[i]);
//I understand the reason behind the following two lines but not the above line.
//printf("noOfElementsInArray=%d\n",*array);
//*array++;
}
}
int main()
{
int array[8]={2,8,10,1,0,1,5,3};
int noOfElementsInArray;
noOfElementsInArray=sizeof(array)/sizeof(int);
printf("noOfElementsInArray=%d\n",noOfElementsInArray);
FunctionApi(array);
return 0;
}