But the problem I'm having is that the array is of course an array of strings. Which makes it an array of arrays of chars.
You should be using a string type anyway, and then you would have an array of string types--not char arrays. You also wouldn't have to use strcpy() and strcat() to perform string operations, you could just use assignments and string addition:
Code:
string str = "hello" + " world";
This works fine for me:
Code:
char * s;
s=new char[20];
strcpy(s,"Lemmings.");
//doesn't like char s[20];
Add a cout statement and see for yourself:
Code:
char * s;
s=new char[20];
strcpy(s,"Lemmings.");
//doesn't like char s[20];
cout<<s<<endl;
As for this:
Code:
char** array;
array = new char*[50];
...
*array+=e;
'array' is a pointer to the first element of the array, where array[0] is the first element of the array, and therefore *array is the first element itself or array[0]. array[0] is a pointer, and it points to the first character of a char array. So, if you advance array[0], or *array, by 1 then you move the pointer array[0] to the second character in the char array--not the next element of 'array' which is array[1].
You can easily test that to see what is happening:
Code:
char** array;
array = new char*[50];
array[0] = "hello";
array[1] = "world";
*array+= 1;
cout<<*array<<endl;
That is equivalent to this:
Code:
char** array;
array = new char*[50];
array[0] = "hello";
array[1] = "world";
array[0] += 1; //*array is the same as array[0]
cout<<*array<<endl;
If you want to advance a pointer from array[0] to array[1], then you have to do something else. Here's how:
Code:
char** array;
array = new char*[50];
array[0] = "hello";
array[1] = "world";
char** parray = array;
parray++;
cout<<*parray<<endl;