I have a simple function in which an array is declared with size depending on the parameter which is int.
void f(int n){ char a[n]; }; i
Your method of allocating from the stack is a g++ extension. To do the equivalent under MSVC, you need to use _alloca:
char *a = (char *)_alloca(n);