Results 1 to 5 of 5

Thread: function that takes a 2D array as a parameter

  1. #1
    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. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: function that takes a 2D array as a parameter

    Call it like this:

    scanning (p1, PI / 2, circ);

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    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. #4
    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. #5
    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])

Similar Threads

  1. Parameter function and generic pointer
    By Rubero in forum Software Development
    Replies: 7
    Last Post: 25-09-2010, 09:04 PM
  2. Pointer parameter in a function
    By Chrisch in forum Software Development
    Replies: 4
    Last Post: 14-12-2009, 10:57 PM
  3. Matrix parameter function
    By Chrisch in forum Software Development
    Replies: 3
    Last Post: 02-12-2009, 11:07 AM
  4. Passing function parameter and static
    By Banjiji in forum Software Development
    Replies: 3
    Last Post: 27-10-2009, 07:32 PM
  5. Pass an array as parameter via URL param
    By Cadallic in forum Technology & Internet
    Replies: 3
    Last Post: 25-07-2009, 12:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,530,784.09929 seconds with 17 queries