can anybody give me an example on a double pointer array?

This is a discussion on can anybody give me an example on a double pointer array? within the C Programming forums, part of the General Programming Boards category; lets say I have **array[x][y]; where x and y are other pointers *x and *y. if that's possible. I want ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    39

    Cool can anybody give me an example on a double pointer array?

    lets say I have **array[x][y];
    where x and y are other pointers *x and *y.
    if that's possible. I want to know how I would use a double pointer array to access the values in it or to pass them to another variable or array. The thing with the double pointers is really confusing in C.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    What are you actually trying to do? **array[x][y] is an array with two dimensions, of pointers to pointers.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    39

    Cool

    I'm just trying to understand how **array works. Can you give me an example on how you would use **array to access the data in the array, or input data into the array?

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Do you know how an array works?
    ... No: Arrays in C - Cprogramming.com

    Do you know how a pointer works?
    ... No: Pointers in C - Tutorial - Cprogramming.com

    Do you know how a pointer to a pointer works?
    ... No: Go back and read this again.

    If you know all of the above, then you should have your answer. If not, get reading.


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    23
    Quote Originally Posted by torquemada View Post
    lets say I have **array[x][y];
    where x and y are other pointers *x and *y.
    if that's possible. I want to know how I would use a double pointer array to access the values in it or to pass them to another variable or array. The thing with the double pointers is really confusing in C.
    You need first to intialize your array (the xMax dimension). Then you need to initialize every row (the yMax dimension). After you done that you can use it like a normal array. Also, you may find useful to deallocate your array when you no longer need it.

    You may find this useful:
    Dystopian Code: Dynamic Multidimensional Arrays in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. double pointer to 2 dimensional array
    By siperi in forum C Programming
    Replies: 3
    Last Post: 12-07-2010, 11:33 AM
  2. Double pointer & Two Dimensional Array
    By vijay s in forum C Programming
    Replies: 2
    Last Post: 12-11-2009, 10:13 PM
  3. array of pointer give error above 11
    By guest18 in forum C Programming
    Replies: 17
    Last Post: 08-18-2009, 09:58 PM
  4. Allocating a double pointer as an array
    By sharrakor in forum C Programming
    Replies: 3
    Last Post: 04-16-2009, 08:02 AM
  5. double pointer to 2-dim array?
    By vex_helix in forum C Programming
    Replies: 2
    Last Post: 04-06-2004, 01:31 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21