I'm trying to create a pointer to a 6
element int
in a function to return it later, so for that purpose I'm using malloc
, but it seems to be acting not as I expected. Here's the code:
int j = 0;
for (;j < 5; j++) {
int * intBig = malloc(j * sizeof(int));
printf("sizeof intBig - %ld\n", sizeof(intBig));
}
Prints the same number 8
bytes as the sizeof(intBig)
at each iteration. Whereas I would expect a series of 4, 8, 12, 16
. What am I missing in this instance?