I am trying to write a program that calls a custom function. Unfortunately, once it enters the function, it ceases to print what I told it to and gets stuck indefinitely. (I run a mac 10.9, and the newest Xcode)
The two functions are:
int main(void)
{
string filePath;
treeNode* root;
int words;
//filePath = getFileName();
cout << "Choosing pathway.\n";
root = readIn(words, "/Users/Noah/Desktop/SmallFile.txt");
cout << "File read.\n";
root->printInOrder(root);
}
and:
treeNode* readIn (int& count, string file)
{
cout << "Here. ";
treeNode* root = new treeNode;
string insert;
ifstream reading;
count = 0; // DECLARE VARIABLES!
int size = 0;
cout << "Made variables. ";
reading.open(file); // Open and check file
cout << "File up. ";
//for (int i = 0; i < 15; i++) // See coder's note at top.
while (!reading.eof())
{
cout << "In loop. ";
char c = reading.get(); // Obtain character to check
if (isalnum(c))
{
insert += c; // Word Storage update
}
else
{
if (count != 0)
{
insertWord(insert, root); // Insert word
insert.clear();
size = 0;
count ++;
}
}
}
reading.close();
return root; // Gives top node back.
}
My question is: Are there any obvious errors that would cause this? If not, is it compiler related? And is there anything I can do about it?