October 12th, 1999, 09:24 AM
HELP, Please!!!
How do I declare, dynamically create and use a double-subscript array of character pointers??? EX: If it is done statically, I would do this:
char *myarry[num_rows][num_columns];
I don't know how many rows there will be so I want to do it dynamically. The number of columns is fixed at three. The problem is, I'm stupid when it comes to pointers to pointers and dynamic allocation. Can someone show me the light? I thought it should look something like this:
char *buffer = "sentence";
char **words;
words = new char*[rows][3];
words[row][col] = buffer;
but the Microsoft Visual C++ 6.0 compiler won't accept it because the types don't match. What am I doing wrong?
Thanks!
jeff_caswell@techpointer.com
How do I declare, dynamically create and use a double-subscript array of character pointers??? EX: If it is done statically, I would do this:
char *myarry[num_rows][num_columns];
I don't know how many rows there will be so I want to do it dynamically. The number of columns is fixed at three. The problem is, I'm stupid when it comes to pointers to pointers and dynamic allocation. Can someone show me the light? I thought it should look something like this:
char *buffer = "sentence";
char **words;
words = new char*[rows][3];
words[row][col] = buffer;
but the Microsoft Visual C++ 6.0 compiler won't accept it because the types don't match. What am I doing wrong?
Thanks!
jeff_caswell@techpointer.com