Well, one way to get around your problem is using something like a pointer to a variable that gets updated when an element is displayed. Something like
Code:
int _printn(NODE *tree, int n, int *currentNum)
{
if (!tree)
return 0;
_printn(tree->left, n, currentNum);
*currentNum = *currentNum + 1;
if (*currentNum == n)
{
printf("%s\n",tree->word);
printf("lool");
return 1;
}
_printn(tree->right, n, currentNum);
}
And this function would be called from another function, to encapsulate the mess
Code:
int printn(NODE *tree, int n)
{
int i = 0;
return _printn(tree, n, &i);
}
Might work, didn't test. But this is not really good looking, there might be better way to do it.