I am trying to assign values for a double pointer and I could not do it because when my pointer is locally declared it is working fine and when I declare it globally then it is not working. Here are the codes for the above mentioned scenarios
// Declared Globally, Not Working
#include<stdio.h>
#include<stdlib.h>
int **x;
int main() {
x=(int**)malloc(sizeof(int*));
x[1][2]=10;
printf("%d",x[1][2]);
}
// Declared Locally, Working fine
#include<stdio.h>
#include<stdlib.h>
int main() {
int **x;
x=(int**)malloc(sizeof(int*));
x[1][2]=10;
printf("%d",x[1][2]);
}