I can't understand why when I'm calculating the num of elements of 'A' in main(), so the result is correct. But when I pass the 'A' to function myfunc() and calaculating there so the result is incorrect.
Can please someone explain me?
typedef struct
{
char description[30];
unsigned price;
}Car;
void myfunc(const Car A[])
{
//The result is 0
int i = sizeof(A)/sizeof(A[0]);
}
void main()
{
Car A[]={{"Fiat punto (red)", 160000},
{"Cadilack",500000},
{"Subaru 1600 second hand",90000},
{"Volvo 3000 10 years old",130000},
{"Mazda 3, 2000, from 2006", 142000}};
//The result is 5
int i = sizeof(A)/sizeof(A[0]);
}
Thank you.