I want to print only n first elements from bst tree so i added global variable counter
int a = 0;
void print (wezel **korzen,int x)
{
if((*korzen) != NULL && (a < x))
{
print( &((*korzen)->lewe),x );
a++;
printf("%s %d\n", (*korzen)->wartosc, (*korzen)->ile);
print( &((*korzen)->prawe),x );
}
}
but this condition in if does not work ? where i made mistake ?
As I mentioned in my comments, you don’t check a after the first print: