--- In [email protected], "jiou0962" <[EMAIL PROTECTED]> wrote:
>
> Hi,
> 
> Followed my previous post, I want to sum up my question again.
> 
> How to pass a two D array as parameter into fuction when the first 
> index of array need to be fixed ?
> 
> Please help if you can, much appreciated! 
> 
> Yibin
>

/*
well, here is an example in good old C. it creates a two dimntional
character array. Note that there are no Strings in C yet there are
some in C++ and other languages. This example can work for other data
types like integers floats, etc etc.
*/

//declare a 2 string character array.  
char maskData[numberOfROWS][numberOfColmns];

//since is a string copy string one into the first row. Notice that we
//do this because is a string. You do not use the string copy function
//for integers or other types. I did it this way because there must be
//millions of examples with integers but only a handfull with strings
//or character.

strcpy(&maskData[0][0], "SOme STring in row one);

//Copy string two into the second row.
strcpy(&maskData[1][0], "A String in row two);

//now pass the 2d array as an argument. Note that I'm also passing
//another variable that is not necessary to pass but is nice to see
//there.

  someFunction(someIntegerVarriable, twoDarray); 


//Finally here how the function will look like on the receiving end
//Note that you must specified the size of the rows and columns.

void someFunction(int someVar, char a2DArray[2][numberOfColums])
{
....
....
}

Reply via email to