You need to allocate memory for the 2d array that you want to do (which I think you understand). But first, you will need to allocate space for pointers, where you will store the strings of the 2D array.
int **data=(int**)malloc(sizeof(*data)*5);
Now you can allocate space for each row.
for(int r=0;r<5;r++){
data[r]=(int*)malloc(sizeof(**data)*5);
}
If you need a continuous block of memory for the entire array, you can allocate one dimensional array of size 25 and access it as data[r*5+c].
PS: sizeof(*data) sizeof(**data) sizeof(int*) sizeof(int), *
PS: ++, malloc (. ).