Allocated a 50*sizeof(int)
of dynamic memory using malloc
. As I read in some document the immediately below element should be a size of allocated memory using malloc
(In my case it is 200 bytes). But when i executed this below code, got 209 instead 200!
#include<stdio.h>
#include<malloc.h>
int main()
{
int *p = (int *)malloc(sizeof(int)*50);
int i;
for(i = 0; i < 5; i++)
scanf("%d", &p[i]);
for(i = -1; i < 5; i++)
printf(" %d ", *((int *)(p+i)));
free(p);
}
Can somebody help whats wrong?