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];
};
int main() {
return 0;
}
This piece of code compiles fine on GNU C++, but not on MSVC 2005.
I get the following compilation errors:
.\main.cpp(4) : error C2057: expected constant expression
.\main.cpp(4) : error C2466: cannot allocate an array of constant size 0
.\main.cpp(4) : error C2133: 'a' : unknown size
What can I do to correct this?
(I'm interested in making this work with MSVC,without using new/delete)