I'm with a doubt In initialization of this in C++:
char** A_Function()
{
char** charList = new char*[2];
charList[0] = "abcde";
charList[1] = "fghij";
return charList;
}
There's no problem "on compiling this code", but I'm not sure about the behaviour.
1 - the char list: char* is on heap ok? 2 - the charList[n_position] is on heap or stack?
I don't understand what char*[2] realy means, does it mean: Its a static array that have on each of its element a pointer to a char?
If it is static this array will be allocated on stack, so this array is a huge bug maker?
If I'm right, how to allocate it on heap?