So here's my recursive function that's supposed to print out an expression tree. The root of the following tree is passed in. I'm pretty sure the tree is created correctly based on some print statements I put earlier in the program. It prints the check three times, then seg faults,(I also tried putting the print statement between the int declaration and the if statement and got the same printout: three checks) so there must be some issue with calling the function when currentPtr is pointing at 5?? That is the first integer it comes to, but all the nodes are of type TreeNode(which just consists of a a string called Op which holds the operator/operand and two TreeNodePointers, leftPtr and rightPtr.
void arithmetic_expression::printExpressionTreeHelper(TreeNodePtr currentPtr, int indent)
if (currentPtr != NULL)
cout << "check";
printExpressionTreeHelper(currentPtr->rightPtr, indent+5); //doesn't run when calls '5'
cout << "check2";
for (i=1; i <= indent; i++)
cout << " ";
cout << "2";