This is my code, it compile and runs:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j;
int** p = (int **)malloc(2 * sizeof(int *));
p[0] = (int *)malloc(2 * sizeof(int));
p[1] = p[0];
for(i = 0; i < 2; i++)
{
for(j = 0; j < 2; j++)
{
p[i][j] = i + j;
}
}
printf("p[0][0] = %d",p[0][0]);
return 0;
}
When this program is run, I got: P[0][0] = 1. Why not P[0][0] = 0?