|
-
January 10th, 2008, 02:58 AM
#1
Passing two dimensional array in function
Hi all,
I want to pass two dimensional array in a function. The function is publicly exposed, so array length cannot be static. I want to check if the function signature is correct.
void Display(int rows, int cols, const char *const *paramValues)
{
int i;
for( i = 0; i < (rows * cols); i++ )
{
printf( "paramValues[%d] = %s\n", i, paramValues[i] );
}
}
int main( int nargs, char *args[] )
{
char *paramVals[5][2];
char a[5][10] = { "Test_1", "Test_2", "Test_3", "Test_4", "Test_5" };
char b[5][10] = { "Hello_1", "Hello_2", "Hello_3", "Hello_4", "Hello_5" };
int i;
for( i = 0; i < 5; i++ )
{
paramVals[i][0] = a[i];
paramVals[i][1] = b[i];
}
Display( 5, 2, paramVals);
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|