I have a struct:
struct Thing {
int id;
}
Then I create an array of Thing
s:
struct Thing *a;
a = (struct Thing *) malloc(sizeof(struct Thing));
a->id = 1;
struct Thing *b;
b = (struct Thing *) malloc(sizeof(struct Thing));
b->id = 2;
struct Thing *array[] = {a,b};
I check the size of the array and is 2. I check the size of array by:
printf("%d",sizeof(array)/sizeof(array[0]));
I also have a function that takes in an array of Things:
void function(struct Thing *array[]) {
//do stuff
}
Then I pass in the array to function:
function(array);
Inside the function, the size of the array is 1. Can someone point to me where did I go wrong and why is the size of the array 1 inside of the function?