Does it possible to pass a 2 dimensional array to a funciton? does it accepts?
Can it be past by value
No.
Again, this is standard 'C' stuff - nothing specifically to do with Keil C51.
So, go back to your 'C' textbook and review how 'C' handles arrays - of all dimensions!
http://www.keil.com/books/genbooks.asp http://c-faq.com/
I'm not going to go trawling through the reference books on this (I'll leave that to others who aren't so busy, or have to for an assignment), but I think you can pass an array by value. Even multi-dimensional ones.
If you cannot do it directly, then you can enclose it in a structure and pass the structure by value.
As to why??? Maybe someone can see a reason, but it sure sounds like something to be treated with caution to me.
No, you can't.
"If you cannot do it directly..."
Which you can't
"...then you can enclose it in a structure and pass the structure by value."
Yes, you could do that.
"As to why??? Maybe someone can see a reason"
The usual "good programming practice" (sic?) reason for which you'd pass any parameter by value if you didn't specifically want the function fiddling with the "original" item.
The reason for not doing it, of course, is the cost of copying (potentially) very large amounts of data - especially for an 8051...!!
I'm not going to go trawling through the reference books on this
why not?
"why not?"
Because I don't want to get drawn into a prolonged discussion on something that has no real value to me.
I normally refer to the reference manuals and standards when I:
1 - Have time 2 - Need to learn something new 3 - Need clarification on something
(not an exhaustive list)
Whoops - Looks like I'm getting sucked in!
Bye.
seems applicable...
;-)
"Looks like I'm getting sucked in!"
Bwa Ha Haaaaaaaaaaaaaa!
You cannot resist - it is your Destiny...
C++ has pass-by-reference. Pascal has pass-by-reference.
C only has pass-by-value.
Note that pointers are also passed by value.
But the particular value that is passed for an array is the address of the array - not the content of the array!
So arrays are effectively passed by "reference"...
"So arrays are effectively passed by "reference"..."
Yes, that could be considered a valid interpretation.
Typically when a structure is passed by value, the compiler allocates space for a copy of that structure (for example, 80x86 would 'borrow' space from the stack), copy the structure across and then pass a pointer to that newly allocated space.
So, on an 8051, this would obviously be quite a cycle intensive operation. As I said before "... something to be treated with caution ...".
Oh shucks, I'm being dragged in again (sob-sob).