Can we pass a matrix as an argument to a function..
means can we have the function declaration like this..
int matrix(int a[i][j])
{
}
then how can we call this function....
|
Go4Expert Founder
|
![]() |
| 26Apr2007,14:43 | #2 |
|
What made you think we cannot have something like that.
|
|
Light Poster
|
|
| 26Apr2007,14:47 | #3 |
|
So then we cant pass an array as a argument means how to use an arrray in called function
|
|
Team Leader
|
![]() |
| 26Apr2007,16:18 | #4 |
|
You an pass an array as an argument, but not like that. The lowest dimension is the only dimension that may indicated by [], all others must have a constant expression. Furthermore, you are not passing an array, but a pointer to an array. Consequently, you should pass in some size information or expect bounds violations.
|
|
Light Poster
|
|
| 26Apr2007,16:54 | #5 |
|
Can u give me an example how to pass an array as the argument to the function
|
|
Team Leader
|
![]() |
| 26Apr2007,18:05 | #6 |
|
Code:
int matrixDisplay (int a[3][], unsigned size)
{
....
}
int main ()
{
myMatrix [4][12] = {....whatever};
....
matrixDisplay (myMatrix [4][], 48);
....
}
|


