Thread: sorting with pointer of pointers to array

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    2

    sorting with pointer of pointers to array

    pictures are word a thousand words, so here is what i need to do...
    http://i153.photobucket.com/albums/.../untitled-3.jpg
    i got a dynamic part of D done, (kinda easy, but little crazy with dynamic delete/add :P) then i try and point the pointer of pointers to D... this is where i get confused. i make a pointer of pointer
    **P and **Q
    i make the pointer array of D, then make the pointer point to an array of the size of D
    *P = new int[DSize];
    *Q = new int[DSize];
    now i get lost...
    i want to make the *P to make the space for the size D, then i want those pointers, **P, to point to the locations of D, but i can figure it out... i can do it with a single pointer *P, but as soon as i do it with a double pointer P, it wont let me do anything with the dynamic array... i even tried casting it as (int *), which works, but it doesn't change a **** thing. any hints?
    here is my pathetic attempt to make the make the pointer go to D in my code...
    *P = D;
    *Q = D;

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Image link is corrupted.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by Yarin View Post
    Um, goodbye duck?
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #5
    Registered User
    Join Date
    Sep 2007
    Posts
    2
    Quote Originally Posted by Yarin View Post
    wow... i am going to cry. */

    meow!!!
    its not a duck! :P

    http://i153.photobucket.com/albums/s...untitled-3.jpg

    why it didn't work i dont know... maybe this will, its the same link...

  6. #6
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Don't shoot the duck, man!

    This sounded similar.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  7. #7
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Image link working now!
    Code:
    *P = new int[DSize];
    *Q = new int[DSize];
    This is wrong already. you shouldn't be trying to create an array of new ints. You need to create a new array of int pointers new (int*)s. You can't assign to *P or *Q until P and Q have been asigned to either. It sounds like you have their declarations correct though.
    Last edited by iMalc; 10-01-2007 at 11:28 PM.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. array of pointers to an array pointers
    By onebrother in forum C Programming
    Replies: 2
    Last Post: 07-28-2008, 11:45 AM
  2. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  3. Question regarding Memory Leak
    By clegs in forum C++ Programming
    Replies: 29
    Last Post: 12-07-2007, 01:57 AM
  4. Array of Pointers to Arrays
    By Biozero in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 02:31 PM
  5. delete and delete[]
    By Hunter2 in forum C++ Programming
    Replies: 13
    Last Post: 06-26-2003, 04:40 AM