Hi,
As part of my ongoing c programming education, I have written a program to use void pointers in a function, however, I am experiencing a strange issue for which I would appreciate some assistance...
Code:
#include <stdio.h>
#define MAX_NUMBERS 10
size_t size(void *object);
int main(void) {
int numbers[MAX_NUMBERS] = { 0,1,2,3,4,5,6,7,8,9 };
printf("sizeof() = %d\n",sizeof(numbers));
printf("size() = %d\n",size(numbers));
return 0;
}
size_t size(void *object) {
return sizeof(object);
}
When I run the program I get the following output:
Code:
sizeof() = 40
size() = 4
Now I think that the result 4 is the size of the pointer, so I'm confussed as why it doesn't give me the same result as 40.
I'm sure i've missed something real simple
Thanks