Click here to Skip to main content
15,909,652 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Fairly basic pointer/array question Pin
Nelek21-Aug-07 20:14
protectorNelek21-Aug-07 20:14 
GeneralRe: Fairly basic pointer/array question Pin
cp987621-Aug-07 21:12
cp987621-Aug-07 21:12 
GeneralRe: Fairly basic pointer/array question Pin
Nelek22-Aug-07 1:20
protectorNelek22-Aug-07 1:20 
GeneralRe: Fairly basic pointer/array question Pin
MALDATA22-Aug-07 4:18
MALDATA22-Aug-07 4:18 
GeneralRe: Fairly basic pointer/array question Pin
Nelek22-Aug-07 4:55
protectorNelek22-Aug-07 4:55 
GeneralRe: Fairly basic pointer/array question Pin
MALDATA22-Aug-07 8:39
MALDATA22-Aug-07 8:39 
GeneralRe: Fairly basic pointer/array question Pin
Nelek22-Aug-07 20:01
protectorNelek22-Aug-07 20:01 
GeneralRe: Fairly basic pointer/array question Pin
cp987622-Aug-07 20:40
cp987622-Aug-07 20:40 
Why are you messing around with sizeof(). The normal way to access members of the array is:

cout << "The array contains..." << endl;<br />
<br />
// This prints out garbage.<br />
cout << myArray[0]->toString() << endl;<br />
cout << myArray[1]->toString() << endl;<br />
cout << myArray[2]->toString() << endl;


This also has the advantage of keeping the myArray pointer, which you will need to delete the memory.

I'm not 100% sure what is happening in your old code, but by default the compiler will take ptr++ as moving ptr to the next element in the array. If one of the gurus reads they will probably be able to tell you, but I guess that to make your code work:

myArray+=sizeof(node*);

you would have to cast the myArray pointer to void*.



Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

QuestionCreateDirectoryA can not be resolved Pin
George_George21-Aug-07 16:27
George_George21-Aug-07 16:27 
AnswerRe: CreateDirectoryA can not be resolved [modified] Pin
Paresh Chitte21-Aug-07 18:36
Paresh Chitte21-Aug-07 18:36 
GeneralRe: CreateDirectoryA can not be resolved Pin
George_George21-Aug-07 20:51
George_George21-Aug-07 20:51 
GeneralRe: CreateDirectoryA can not be resolved Pin
Paresh Chitte21-Aug-07 22:05
Paresh Chitte21-Aug-07 22:05 
GeneralRe: CreateDirectoryA can not be resolved Pin
George_George21-Aug-07 22:23
George_George21-Aug-07 22:23 
AnswerRe: CreateDirectoryA can not be resolved Pin
David Crow22-Aug-07 2:30
David Crow22-Aug-07 2:30 
GeneralRe: CreateDirectoryA can not be resolved Pin
George_George22-Aug-07 3:16
George_George22-Aug-07 3:16 
QuestionEncoder Pin
celllllllll21-Aug-07 12:08
celllllllll21-Aug-07 12:08 
QuestionRe: Encoder Pin
celllllllll21-Aug-07 12:27
celllllllll21-Aug-07 12:27 
AnswerRe: Encoder Pin
cp987621-Aug-07 13:29
cp987621-Aug-07 13:29 
AnswerRe: Encoder Pin
El Corazon21-Aug-07 13:48
El Corazon21-Aug-07 13:48 
GeneralRe: Encoder Pin
celllllllll21-Aug-07 14:33
celllllllll21-Aug-07 14:33 
GeneralRe: Encoder Pin
El Corazon21-Aug-07 15:03
El Corazon21-Aug-07 15:03 
AnswerRe: Encoder Pin
Stephen Hewitt21-Aug-07 14:35
Stephen Hewitt21-Aug-07 14:35 
GeneralRe: Encoder Pin
celllllllll21-Aug-07 14:39
celllllllll21-Aug-07 14:39 
GeneralRe: Encoder Pin
Maximilien21-Aug-07 15:16
Maximilien21-Aug-07 15:16 
QuestionHelp With Dialog Based App Pin
simoncoul21-Aug-07 8:41
simoncoul21-Aug-07 8:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.