Ok. You asked your question simple enough. :)
I want to have array of poiners to array of chars...
You're on the right track. At the very least that is char *[]
. However, as we all know, that can easily be translated to char **
. Of course, to have a pointer to the storage, you need to add the third star. You're correct so far in your question.
how to store pointer to that const char * value to my DbRecord on position [0]
Well there are two ways to do it. The correct answer to the question the way you asked it is to dereference the pointer. For example:
bool AddToArray(const char* value,
const char *** database)
{
bool success = false;
((*database)[0]) = value;
if ( (*database)[0] == value ) success == true;
return success;
}
Technically, accessing a pointer as an array will also dereference it as an index. So the [0]
there will dereference the pointer straight. Depending on how you lay out your allocations and memory, you could also do it like this:
...
(*(database[0])) = value;
...
Note the subtle difference there. Where the first example treated it as a pointer to an array of pointers (or a pointer to an array of arrays, depending on how you think of it), this second example treats it as an array of pointers to an array (or an array of pointers to pointers).
Learning to master multiple levels of pointers is one of the best things you can do as a C developer but it's generally a frowned-upon practice in C++.
Hope this helps.
Edit: char *[]
not char [][]