Thread: pointers

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by std10093 View Post
    You pass the array as I said and you handle it normally (of course not as you say...)
    No. Your example only considers single-dimensional arrays. With an n-dimensional array passed as input into a function, the compiler needs to "know" about the the size of the highest n-1 dimensions of the array. In addition, the programmer needs to know the size of the lowest dimension of the array as well as where the array begins in memory. So in total, you must design your function to accept n+1 parameters. This fact is true independent of whether you use the C99 syntax or C89 syntax. Using the C99 syntax simply lets you use indices inside the function in a natural mathematical way, i.e. "in the normal way".

  2. #2
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Yes is the answer. When you want to pass a n dimensional array you pass n stars as pointers and n dimensions. So simple.

    Also, I suppose you understood your mistake before... I guess actually it won't even compile. Tip : Compile the code before you post it

    Enough said and this thread is solved.

    Bye
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    24
    files and sockets come to mind also.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. size of struct with pointers and function pointers
    By sdsjohnny in forum C Programming
    Replies: 3
    Last Post: 07-02-2010, 05:19 AM
  2. Storing function pointers in generic pointers
    By Boxknife in forum C Programming
    Replies: 6
    Last Post: 08-01-2009, 01:33 PM
  3. Pointers to objects -- passing and returning pointers
    By 1veedo in forum C++ Programming
    Replies: 4
    Last Post: 04-04-2008, 11:42 AM
  4. Problem with malloc and pointers to pointers
    By mike_g in forum C Programming
    Replies: 7
    Last Post: 03-29-2008, 06:03 PM
  5. weak pointers and use_count smart pointers
    By Mario F. in forum C++ Programming
    Replies: 2
    Last Post: 07-29-2006, 07:54 AM