How can I declarate a matrix of strings?

if I write something like the line below, my code do not compile


string a[MAX][MAX];


someone can give me a solution?
thanks

Try: vector<string> str; The [] for string is overloaded, to mean other things.

A vector of vectors of STL strings instead of an array of arrays might be better since STL strings usually aren't length limited as is required by arrays. I think this is the correct syntax for that. (Keep spaces between the angled braces so the compiler doesn't think you are using input/output operators.)

vector<vector<string> > stringMatrix.

If you want to limit the length of the string then maybe using a C style array of C style strings is better:

char a[MAX][MAX][MAX];

might be better.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.