#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;
}
Not used int arr[n], where n is a variable illegal in C? I am trying to understand what is happening here. Apparently, the code works on mine clang LLVM compilerand on IDEOne and on Codeblocks. I think that the compiler just makes my task easier by making automatic memory allocation. But another amazing fact: when I try to set nto 1, 2 or 3, it still works.
source
share