Original Post
Hey everyone!
Quick pointer question
Say I read in data from a file. I create a pointer to a char array and then pass it to a function that will create a linked list node with it:
char *tempLine = new char[25];
//Pretend now I've filled it with data
functionA(tempLine);
Using a MessageBox in functionA(for ex), I see the data just fine. functionA creates the linked list node, and I try to send tempLine to its constructor:
void functionA(char *tempLine)
{
MessageBox(NULL, tempLine, "blahblah", MB_OK); // shows the data
Node *newNode = new Node(tempLine);
}
Now in the node, the constructor looks like:
Node(char *getData)
Now using a MessageBox to show getData...I just get a bunch of garbage.
Anyone know what I'm doing wrong?
[edited by - nologic on April 21, 2004 9:56:59 PM]