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:


Code:
Tdata 
findMin(const Tree t) 
{
  if (t == NULL) return -1;
  if (t->left == NULL)
  {
	printf("min: %d\n",t->data);       		
	return t->data;
  }
   else findMin(t->left);
}

In main, I do this:
Code:
printf("The min value is %d\n", findMin(t));
(The findMax function does the same but goes to the right.)

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.