Possible Duplicate:
How to pass a multidimensional array to a function in C and C++
so I have char buffer[4][50]
I need to pass it to a method void SetBuffer(char **buffer)
or at least that's how i think it's suppose to be formatted.
so I do SetBuffer(buffer);
? In the method I need to set each element so
void SetBuffer(char **buffer)
{
strncpy(buffer[0], "something", 50);
strncpy(buffer[1], "something else", 50);
}
how can this be accomplished properly?
The C++ way would be to use a proper container (e.g.
std::vector<unsigned char>
orstd::string
) as appropriate.OTOH, if there's a particular reason to fall back on arrays, using pointers (as you already do) and passing in the dimensions explicitly are one way to do it..