C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-30-2007, 05:09 PM   #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;
dunpealslyr is offline   Reply With Quote
Old 09-30-2007, 06:02 PM   #2
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,492
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
CornedBee is offline   Reply With Quote
Old 09-30-2007, 08:33 PM   #3
Unregistered User
 
Yarin's Avatar
 
Join Date: Jul 2007
Posts: 980
Ah. Here, it's working now.
http://i153.photobucket.com/albums/.../untitled-3.jpg
__________________
May the Source be with you.
Yarin is offline   Reply With Quote
Old 10-01-2007, 12:38 AM   #4
Algorithm Dissector
 
iMalc's Avatar
 
Join Date: Dec 2005
Location: New Zealand
Posts: 2,727
Quote:
Originally Posted by Yarin View Post
Um, goodbye duck?
__________________
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
iMalc is offline   Reply With Quote
Old 10-01-2007, 05:14 PM   #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...
dunpealslyr is offline   Reply With Quote
Old 10-01-2007, 06:27 PM   #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.*
Dave_Sinkula is offline   Reply With Quote
Old 10-01-2007, 11:26 PM   #7
Algorithm Dissector
 
iMalc's Avatar
 
Join Date: Dec 2005
Location: New Zealand
Posts: 2,727
Image link working now!
Quote:
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.
__________________
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger

Last edited by iMalc; 10-01-2007 at 11:28 PM.
iMalc is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
array of pointers to an array pointers onebrother C Programming 2 07-28-2008 11:45 AM
Dynamic array of structures containing yet another dynamic array of structures innqubus C Programming 2 07-11-2008 07:39 AM
Question regarding Memory Leak clegs C++ Programming 29 12-07-2007 01:57 AM
Array of Pointers to Arrays Biozero C Programming 2 04-19-2007 02:31 PM
delete and delete[] Hunter2 C++ Programming 13 06-26-2003 04:40 AM


All times are GMT -6. The time now is 04:54 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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