You are really allocating a 2D array. A "string" in c isn't a real data type, it is a special case of an array of characters. In your code, disp is an array of pointers, and that array of pointers are of the type character array. Or, you can think of it as a 2D array of characters. Arrays in C are wonderfully (dangerously?) flexible things.
You can't assign an array in one fell swoop with the "=" operator*. C doesn't do that. Even arrays that don't look like arrays because C is pretending to support strings. That's why there are functions like strcpy()
in the standard C library (but probably not in Arduino's library, due to microcontroller size constraints).
If inString is an array of characters, then al you are doing is assigning the first element of disp to point to the same place that inString points to, hence the behavior you see. Incidentally, this also loses the reference to the original array pointed to by disp[0], resulting in a memory leak.
What you basically have to do is copy the contents of inString to disp[0], one character at a time, checking to make sure that you stop before you trash memory beyond what is allocated for the copy target, and stop when you're at the end of the copy source.
For a contrived example, let's say the strings are always exactly 3 characters long (so the string would be 4 characters, gotta have the null character as a terminator for it to be a string):
for (i=0; i<4; i++)
disp[0][i] = inString[i];
We really want to use the strcpy() function, like so:
strcyp(disp[0], inString);
but we still need to do the test to make sure inString isn't longer that the size of disp[0] (otherwise we trash memory, starting with disp[1], most likely, and working our way on from there).
-j
- without some C++ code and overloading the "=" operator