R
Rafi Kfir
Hi,
This may look as a smiple task to most of you, but to me (a beginner
with C), it drives me crazy.
All I want is that one function passes a two dimensional array of
strings to another function.
example:
NOTE: the strings can be of different length and the array will be
initialized many times to differnt values.
void fun_1()
{
char **Arr[3][2]= {'\0'}; //I want to define a 3x2 array of strings
of
//different length (max 32 ch)
//Arr initialization
// Arr ["ONE", "1"]
// ["Two", "2"]
// ["THREE", "3"]
fun2(Arr);
}
void fun_2(char **rcvArr)
{
}
CAn anybody help me with how to define it, how to initialize it and
hwo to send and receive it as a parameter.
I suspect that I must define some buffer length. The question is
should I select fixed length (e.g. 32 ch per string) or a veriable
length. In the other option I would probably need to use malloc in
order to allocate memory...
I would be happy to be advised of the best way to do it. Also, when I
initialize the array, I preffer that it will take as little text space
as possible (for example, the best will be to define it all in one
line!).
Thanks for helping
Rafi
This may look as a smiple task to most of you, but to me (a beginner
with C), it drives me crazy.
All I want is that one function passes a two dimensional array of
strings to another function.
example:
NOTE: the strings can be of different length and the array will be
initialized many times to differnt values.
void fun_1()
{
char **Arr[3][2]= {'\0'}; //I want to define a 3x2 array of strings
of
//different length (max 32 ch)
//Arr initialization
// Arr ["ONE", "1"]
// ["Two", "2"]
// ["THREE", "3"]
fun2(Arr);
}
void fun_2(char **rcvArr)
{
}
CAn anybody help me with how to define it, how to initialize it and
hwo to send and receive it as a parameter.
I suspect that I must define some buffer length. The question is
should I select fixed length (e.g. 32 ch per string) or a veriable
length. In the other option I would probably need to use malloc in
order to allocate memory...
I would be happy to be advised of the best way to do it. Also, when I
initialize the array, I preffer that it will take as little text space
as possible (for example, the best will be to define it all in one
line!).
Thanks for helping
Rafi