hello,
i am obviously missing a big point on recursion.
this is an excercise program that prints to the screen one char at a time. the return value is the number of chars entered.
all works fine and well until i decide to add the printf at the end of the function, which prints the the chars in the previous functions. the question is, why does the return value change once the printf is enabled?
thanks!
(written with borland c builder)

#include <conio.h>
#include <stdio.h>
int func(int);
void main(void)
{
int d=func(0);
printf("\ndepth=%d",d);
getch();
}

func(int d)
{int x;
printf("%c",x=getch());
if (x!=' ') func(d+1);
else
return d;
//printf("%c",x);


}