Tree printing using C

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

struct node{
int item;
struct node *left;
struct node *right;
};

struct node build()
{
struct node ptr;
int data;
printf(“enter data\n”);
scanf("%d",&data);
if(data==-1)
return NULL;
ptr=(struct node
)malloc(sizeof(struct node
));
ptr->item=data;
printf(“enter data at the left child of %d\n”,ptr->item);
ptr->left=build();
printf(“enter data at the right child of %d\n”,ptr->item);
ptr->right=build();
return ptr;
}

void print(struct node *ptr)
{
if(ptr!=NULL)
{
printf("%d \n",ptr->item);
print(ptr->left);
print(ptr->right);
}
}

int main()
{
struct node *ptr;
printf(“BUILD YOUR BINARY TREE\n”);
ptr=build();
printf(“BINARY TREE\n”);
print(ptr);
return 0;
}
bhaiya I am getting error in printing tree

Please save your code on ide.codingblocks.com and share its link. It is easy for us to debug there.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.