# Passing a row of a Multidemensional Array to a function

This is a discussion on Passing a row of a Multidemensional Array to a function within the C Programming forums, part of the General Programming Boards category; Let's say I have 2D array of N rows and M columns, how do pass one of the rows of ...

1. ## Passing a row of a Multidemensional Array to a function

Let's say I have 2D array of N rows and M columns, how do pass one of the rows of this array to a function and the function can use this row as a 1D array? Thanks.

2. Code:
```void foo( data_type array[SIZE] )
{

}

...

data_type array[ROWS][SIZE];

foo( array[x] );```
Enjoy.

Quzah.

3. >>>void foo( data_type array[SIZE] )
when defining this function, do I must specify the array size as SIZE (here it corresponds to number of columns) ?

4. Passing a row to it is actually passing a pointer to the first element in whatever row. The size specifier was really just for illustration. Consider the following:
Code:
```#include <stdio.h>
#define SIZE 10

void foo( char array[] )
{
printf("array is: %s\n", array );
}

int main( void )
{
char mdarray[][SIZE] =
{
"foo",
"bar",
"barfoo",
"fweeeeee",
"the end",
0
};
int x;

for( x = 0; mdarray[x][0]; x++ )
foo( array[x] );

return 0;
}```
This should run through the list and stop when it hits the null (the zero).

Quzah.

5. ## confirm multi to one row code?

Way back when...quzah wrote:
Code:
```    for( x = 0; mdarray[x][0]; x++ )
foo( array[x] );

return 0;```
was array[x] supposed to be mdarray[x]?

Regards,
Dave

6. Yes. Way to necro a six year old thread!

Quzah.