I have a binary search tree made up of struct tree_st nodes. The struct has members TData (which is just a typedefed int) and pointers to left and right trees. Everything is working fine; test program takes int values and puts them in the tree and then prints out an in-order traversal.
But now I'm trying to add findMin and findMax functions. These also work just fine, as long as I print out the min or max in the function. If I try to return the value and print it out in main, I get the address instead! Weird.
Here's the findMin function:
findMin(const Tree t)
if (t == NULL) return -1;
if (t->left == NULL)
In main, I do this:
(The findMax function does the same but goes to the right.)
printf("The min value is %d\n", findMin(t));
I put the printf in findMin as a test, and sure enough, it prints out the actual integer minimum. But then, returning t->data to main and printing it out prints out an address!!
Any guidance on this would be much appreciated. Thanks.