Hi there,
I am allocating a 1D array of integers by using the malloc function (I report the code down here).
Once allocated the memory, I would like to print to screen the size of such array by means of sizeof(), but it seems that what I obtain does not correspond to the number of elements of the newly allocated array, but the size of one element of type int.
To make it easy: I allocate 13 elements inside array _esup2, but when I printf to screen the sizeof(_esup2), I obtain 4 instead of 13.
What am I doing that is not correct? I need to verify this because the bogger code within this is enclosed crashes for wrong memory allocation.
Here the code, I hope someone can help
Thank you in advance,
All the best
S.M.
Code:
int nnode = 13;
int *_esup2;
_esup2 = (int*) malloc((sizeof(int[nnode+1])));
printf("size(ESUP2) %d\n", sizeof(_esup2));
;