I have a function that takes 2 D character array as parameter
class listview{
int numColumn;
void func(char** data)
{
}
};
The func does not take dimensions, because it is fixed as a data member in the object of which it is member. Its job is to insert a row consisting of a number of columns in a list view.
I want to pass a single 1 D character array to the function because this list view has only 1 column
listview obj;
obj.func(String("Test").GetStr()); //GetStr() returns a char array
How to do it?
That depends entirely on the function and what it does. Why does it take a
char**? Perhaps because it takes an output or an input/output parameter? Or perhaps it treats the parameter as a 2D character map(this is unlikely since it doesn’t take the dimensions). How does it interpret its parameter? Does it index the pointer passed? All these questions need to be answered.In the simplest case of the input/output parameter, I’d recommend this:
If it’s just an output parameter, then I presume the argument needn’t be initialized;