#include "stdio.h"
int main()
{
int n;
printf("Enter n:\n");
scanf("%d",&n);
int arr[n][n];
arr[3][3] = 4;
printf("%d",arr[3][3]);
getchar();
return 0;
}
Wasn't using int arr[n]
, where n is a variable, illegal in C? I am trying to understand what's happening here. Apparently the code works on my clang LLVM compiler
and on IDEOne and on Codeblocks. I guess the compiler is just making things easy for me, by doing automatic memory allocation. But another astounding fact is that when I try to set n
to 1, 2 or 3 it still works.