When I try to check the size of an array that is allocated, it always tells me the size is 8, no matter how many bytes I allocate. When I check the size of an array that is declared the normal way, it gives me the correct size. I figure that it just checks the size of the pointer and not of the array? How can i fix this? Running on a macbook pro
Code:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int *a,b[] = {1,2,3};
a = (int *)malloc(48);
a[0] = 1;
a[1] = 2;
a[2] = 3;
printf("size of b: %li\n", sizeof(b)); -> returns 12
printf("size of a: %li\n", sizeof(a)); -> returns 8
return 0;
}