I was amazed to see that this code is working. I couldn't figure out why
#include<stdio.h>
int main(){
int row,col,i,j;
scanf("%d %d",&row,&col);
int a[row][col];
for(i=0;i<row;i++)
for(j=0;j<col;j++)
scanf("%d",&a[i][j]);
for(i=0;i<row;i++){
for(j=0;j<col;j++)
printf("%d ",a[i][j]);
printf("\n");
}
}
Since C is a compiled language then How it is allocating memory for the array a[row][col] ? Since at the time of compilation the value of row and column are not known, then how it is able to make machine code and set the address space for the program? Why this is working as an interpreter language would have worked, If this is a way to create a dynamic array then why are we taught to use malloc for creating dynamic array in C.