TechArena Community function that takes a 2D array as a parameter

#1
06-05-2009
 Member Join Date: Dec 2008 Posts: 33
function that takes a 2D array as a parameter

hi,
I defined the following function:
Code:
`p_direction scanning (points position, double heading, int circ [NC] [MC]) (....}`
with

Code:
``` struct (int s_point a; y-int);
typedef struct s_point * points;
s_direction struct (double s_ta; double s_dist_obst;);
typedef struct s_direction * p_direction;```
I use my position as follows:
Code:
`  p_direction d = scan (P1, PI / 2., circ [NC] [MC]);`
but this warning appears: warning: passing argument 3 of 'scan' from incompatible pointer.Why? How do I fix this? Thank you in advance for the answer.
#2
06-05-2009
 Member Join Date: May 2008 Posts: 2,008
Re: function that takes a 2D array as a parameter

Call it like this:

scanning (p1, PI / 2, circ);
#3
06-05-2009
 Member Join Date: May 2008 Posts: 2,293
Re: function that takes a 2D array as a parameter

Code:
`p_direction scanning (points position, double heading, int circ [NC] [MC]`
You must send a pointer to a two dimensions to your function.
Code:
`p_direction d = scan (P1, PI / 2., circ [NC] [MC]);`
circ is the pointer, so if you send circ [x] [y] to your function (whatever x and y, since these boxes have been allocated), it retrieves this parameter as a variable int.

Code:
` p_direction d = scan (P1, PI / 2., circ);`
This seems to be better, right?
#4
06-05-2009
 Member Join Date: Dec 2008 Posts: 177
Re: function that takes a 2D array as a parameter

For a table with n dimensions it is necessary to clarify the last n-1, ie all except the first. Nevertheless it seems to me that the first is optional, ie that its accuracy is left to the programmer.
#5
06-05-2009
 Member Join Date: Dec 2008 Posts: 33
Re: function that takes a 2D array as a parameter

I specify only the 2nd dimension of the table:

Code:
`  p_direction scanning (points position, double cap, circ int [TM])`

 Tags: