How to fix the variable length array of non-POD element type 'string'

Hello all:

I am having the issue with compiling my code. In this program my plan is to write the code which is able to take multiple read input files.
error:
1
2
3
4
sequence.cxx:142:29: error: variable length array of non-POD element type 'string' (aka 'basic_string<char, char_traits<char>, allocator<char> >')
    string file_array[n_file];
                            ^
1 error generated.
Last edited on
string file_array[n_file]
Last edited on
file_array[m].c_str();
Last edited on
Let me know if you need input file.
Last edited on
Variable length arrays are not a feature of C++. Whatever compiler extension you're using that does support VLAs does not support using them for non-POD types.

Solution: Don't use variable length arrays. A std::vector<std::string> would work fine here and has the advantage of being portable.
Thanks
It worked.
Topic archived. No new replies allowed.