this code is correct in C#
int x = int.Parse(Console.ReadLine());
int[] t = new int[x];
but in c/c++ in wrong
int n; scanf("%d",&n); int a[n];
how in c# static array allocate in runtime (or in c# array is dynamic?)
this code is correct in C#
int x = int.Parse(Console.ReadLine());
int[] t = new int[x];
but in c/c++ in wrong
int n; scanf("%d",&n); int a[n];
how in c# static array allocate in runtime (or in c# array is dynamic?)
C# arrays are allocated at runtime on the heap.
C arrays are allocated at compile-time on the stack.
C can also allocate arrays at runtime using malloc. (Just remember to free them when you're done)
malloc has rather little place in C++. (It might be interesting if you really know what you're doing and you're doing micro-optimizations, otherwise) you should use new instead. And you should probably not use bare arrays either (unless you have a good reason). The fact that C++ is (mostly) a superset of C, means in C++ you can do anything you can in C, but you really shouldn't.