I get this error in my c++ code Variable length array of non-POD element type string
(aka basic_string
).
string words[n
Sorry, you need to write gcc --version
to get the version.
As others state, you shouldn't use variable-length arrays, but GCC does support them as an extension in C++. My GCC 4.4.4 compiles just fine with the following code:
#include
#include
using namespace std;
int main() {
int n;
cin >> n;
string s[n];
return 0;
}
Does that code compile for you? If it does, then you need to give us the smallest piece of code that fails.
The best solution, though, is to use vector
.