Hello all i'm working for school on a binary tree.
I've made inseriment, simmetric visit, preorder visit, postorder visit and a search function.
The tree is balanced and the search function gets a number and gives as output the number of the node the number is in.
Of course all with recursion.
The teacher wants us to complete the program so if there isn't the number you are searching there's an out like "no number found".
I can't do it with a global variable, i've tried with returns but i really can't understand how to implement this well, if anyone can help....
Here's the code, sry for confusing names but i'm italian...

Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<alloc.h>
struct info{ int valore;
			 struct info *sx;
			 struct info *dx;
		   };
struct info *primo=NULL;

void collegamento(struct info *, struct info *);
void simmetrico(struct info *);
void preordine(struct info *);
void postordine(struct info *);
void ricerca(int, int, struct info *);

void inserimento(void){
			   struct info *nuovo;
			   nuovo=malloc(sizeof(struct info));
			   printf("Inserisci il valore:\n");
			   scanf("%d",&nuovo->valore);
			   nuovo->sx=NULL;
			   nuovo->dx=NULL;
			   if(primo==NULL) primo=nuovo;
			   else	collegamento(nuovo,primo);
			   }

void collegamento(struct info  *dac, struct info  *attuale){
		  if(dac->valore < attuale->valore){
						  if(attuale->sx==NULL) attuale->sx=dac;
						  else collegamento(dac,attuale->sx);
						  }
		  if(dac->valore > attuale->valore){
						  if(attuale->dx==NULL) attuale->dx=dac;
						  else collegamento(dac,attuale->dx);
						  }
			   }

void simmetrico(struct info *elemento){
						 if(elemento!=NULL){
								 simmetrico(elemento->sx);
								 printf("Il valore Š %d\n",elemento->valore);
								 simmetrico(elemento->dx);
								 }
						 }

void preordine(struct info *elemento){
						 if(elemento!=NULL){
								 printf("Il valore Š %d\n",elemento->valore);
								 preordine(elemento->sx);
								 preordine(elemento->dx);
								 }
						 }

void postordine(struct info *elemento){
						 if(elemento!=NULL){
								 postordine(elemento->sx);
								 postordine(elemento->dx);
								 printf("Il valore Š %d\n",elemento->valore);
								 }
						 }
void ricerca(int valore, int nnodo, struct info *elemento){
						 if(elemento!=NULL){
								 if(elemento->valore==valore){
									printf("Nodo %d",nnodo);
									getch();
									}
								 nnodo++;
								 ricerca(valore,nnodo,elemento->sx);
								 ricerca(valore,nnodo,elemento->dx);
							 }
						 nnodo--;
					}


char sc;
int valz;

void main(){
	   do{
		  clrscr();
		  printf("1)Inserimento\n2)Simmetrico\n3)Preordine\n4)Postordine\n");
		  sc=getch();
		  switch(sc){case '1':inserimento();
							  break;
					 case '2':simmetrico(primo);
							  getch();
							  break;
					 case '3':preordine(primo);
							  getch();
							  break;
					 case '4':postordine(primo);
							  getch();
							  break;
					 case '5':printf("Inserisci il valore da cercare\n");
							  scanf("%d",&valz);
							  ricerca(valz,0,primo);
							  break;
					}
		   }while(sc!=27);
		}