I am trying to create a 2D array of the "CString" MFC class, however it needs to be declared dynamically for my application. I have read up on numerous forums but I just cant seem to find what I am looking for.
From what I have read the best way to do this would be to use a vector of CStrings. However, I am not to sure how to declare this dynamically (I am able to do it by specifying the row and column size, however these values are not known at compilation time and therefore i cannot do it this way).
What I would like to be able to do is address any "CString" of a 2D array in the following way:
MyArray="Message ID in CString format" MyArray="Message in CString format" MyArray="Time in CString format" MyArray="Message ID in CString format" MyArray="Message in CString format" MyArray="Time in CString format"
and so on...
As you can see the parts which are variable an therefore dynamic are the "Row" and "CString" values. The "column" value can be set to 3 at compilation time.
Please could someone give me an example of how to do this without having to specify the row and column size.
The following code which i found on another forum is exactly what i would want, using a vector of "CStrings" however although the poster claims it is dynamic the "Width" and "Height" still need to be declared and set at compilation time:
#include <vector> std::vector<std::vector<CString> > your2darray(width, std::vector<CString>(height)); your2darray[x][y] = "asdf";