Code:
void TST::search(char *filename, char *filetype)
{
nodeT *newNode,*curNode;
curNode = root; //keeps track of where we are in our tree
cerr << endl << filetype << endl << curNode->filetype << endl; //good
cerr << strcmp(filetype, curNode->filetype); //doesn't show anything
while(1)
{
if (curNode == NULL) //then we never created such a file
{
cout << "The specified filetype does not exist." << endl;
break;
}
if (strcmp(filetype, curNode->filetype) < 0)
{
curNode = curNode->left; //traverse the tree
break;
}
if (strcmp(filetype, curNode->filetype) > 0)
{
curNode = curNode->right; //traverse the tree
break;
}
if (strcmp(filetype, curNode->filetype) == 0)
{
curNode->bst.search(filename); //filetype exists! Now search the BST for the file
break;
}
}//end while
}//end search
The root node is initially set to null before creation of the trees. If there was.. for some reason, never data added, this does indeed ensure the root node is not null. Further, as mentioned, the curNode->filetype outputs good data.
The cerr statements are just me trying to figure the thing out. I don't know why strcmp doesn't like char*s given that that's how it's defined.
My question boils down to, how can I have good data and get strcmp doesn't work?
EDIT:
Just to say, I'm using Dev C++, and the only way, at the moment, I can get my program window to stay up is to use a line that pauses it before the crash. No good data for errors is really coming out of it either, and the external VC debugger (that I don't think is all that spectacular) doesn't even catch it. The program dies. It died similarly to another memory access problem (which is what I assume this has to do with.)