I know that malloc(n) returns a pointer to a memory of n bytes. Let's say if I want 5 bytes of memory and initialize as an integer array (I know the insufficient number of bytes are allocated).
int *a = malloc(5);
*a = 1234;
*(a+1) = 5000;
printf("%d ",*a);
printf("%d",*(a+1));
As far as I know, the first four bytes are used by 1234 and the second element should have only one byte left. But, the output is1234 5000. How does the second element get the remaining 3 bytes?
Later if I uninitialize the array by free(a), does it free the additional bytes of the second element?