Here is the code that i want to understand:
#include <stdio.h> #include <stdlib.h> #define MAX 100 int main() { int *ptr = (int *)malloc(5 * sizeof(int)),i; for(i=0;i<MAX;i++) { ptr[i] = i; } for(i=0;i<MAX;i++) { printf("%d\n",ptr[i]); } return 0; } My question: I allocated 5 * int size of memory but why it takes more than 5 ineteger? Thnx