Click here to Skip to main content
15,913,055 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Getting Default Action For FIle Type Pin
A Noteworthy Programmer22-Aug-07 3:30
A Noteworthy Programmer22-Aug-07 3:30 
GeneralRe: Getting Default Action For FIle Type Pin
David Crow22-Aug-07 3:39
David Crow22-Aug-07 3:39 
QuestionRegSetValueEx Pin
George_George21-Aug-07 17:13
George_George21-Aug-07 17:13 
AnswerRe: RegSetValueEx Pin
ThatsAlok21-Aug-07 23:55
ThatsAlok21-Aug-07 23:55 
GeneralRe: RegSetValueEx Pin
George_George22-Aug-07 0:11
George_George22-Aug-07 0:11 
QuestionRe: RegSetValueEx Pin
David Crow22-Aug-07 2:47
David Crow22-Aug-07 2:47 
AnswerRe: RegSetValueEx Pin
George_George22-Aug-07 3:13
George_George22-Aug-07 3:13 
QuestionFairly basic pointer/array question Pin
MALDATA21-Aug-07 16:32
MALDATA21-Aug-07 16:32 
So I'm sure everyone else has seen stuff like this, but I'm not sure where in the array/pointer jungle I got lost. Here's a sample... I apologize for the huge chunk of code. A node is just a little class that holds an integer... it's for demonstration purposes. The toString() function is a method which prints out that node's integer.

<br />
#include <iostream><br />
#include "node.h"<br />
<br />
node** makeArray();<br />
<br />
using namespace std;<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
  node** myArray;<br />
  myArray = makeArray();<br />
  <br />
  cout << "The array contains..." << endl;<br />
<br />
// This prints out garbage.<br />
  cout << (*myArray)->toString() << endl;<br />
  myArray+=sizeof(node*);<br />
  cout << (*myArray)->toString() << endl;<br />
  myArray+=sizeof(node*);<br />
  cout << (*myArray)->toString() << endl;<br />
}<br />
<br />
node** makeArray()<br />
{<br />
  node* out[3];  // Make an array of pointers to 3 nodes<br />
<br />
  node* test1 = new node(7);   // Make new nodes and put them in there<br />
  node* test2 = new node(3);<br />
  node* test3 = new node(9);<br />
<br />
  out[0] = test1;   // Fill the array with pointers to the nodes<br />
  out[1] = test2;<br />
  out[2] = test3;<br />
<br />
  cout << out[0]->toString() << endl;  // This part works fine.<br />
  cout << out[1]->toString() << endl;<br />
  cout << out[2]->toString() << endl;<br />
<br />
  return out;<br />
}


The output is
<br />
7<br />
3<br />
9<br />
The array contains...<br />
1310504608<br />
1310520796<br />
-1077666540<br />


So where did I go wrong? By the way, this is all for the sake of learning and understanding, so I'm not looking for an easier way to do this particular job, I'm looking to understand what's going on in this case.

Thanks!
AnswerRe: Fairly basic pointer/array question Pin
cp987621-Aug-07 16:54
cp987621-Aug-07 16:54 
GeneralRe: Fairly basic pointer/array question Pin
MALDATA21-Aug-07 18:17
MALDATA21-Aug-07 18:17 
GeneralRe: Fairly basic pointer/array question Pin
cp987621-Aug-07 19:13
cp987621-Aug-07 19:13 
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 
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 

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.