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
You are using something that is not a standard. Actually it is standard C but not C++. How peculiar is that!
Explaining a bit more, run time sized stack arrays are not part of C++, but are part of C99, the latest standard for C. That´s why some compilers will get it, while others will not. I would recommend refrain from using it, to avoid compiler compatibility issues.
The alternate implementation of the functionality would be using new and delete, as posted by strager.