Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
U

User 12502505

@User 12502505
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • c prgram to display a binary tree but it is not showing any output, what is the error in this program can you help me
    U User 12502505

    #include
    #include
    struct tree
    {
    char info;
    struct tree *left;
    struct tree *right;
    };
    struct tree *root;
    struct tree *stree(struct tree *root,struct tree *r,char info);
    void print_tree(struct tree *root,int l);
    int main(void)
    {
    char s[80];
    int l=3;
    root=NULL;
    do
    {
    printf("enter a letter:");
    gets(s);
    root=stree(root,root, *s);

    }
    while(\*s);
    print\_tree(root,0);
    return 0;
    

    }
    struct tree *stree(struct tree *root,struct tree *r,char info)
    {
    if(!r)
    {
    r=(struct tree *) malloc(sizeof(struct tree));
    if(!r)
    {
    printf("out of memory \n");
    exit(0);

    	}
    	r->left=NULL;
    	r->right=NULL;
    	r->info=info;
    	if(!root)
    	return r;
    	if(infoinfo)
    	root->left=r;
    	else
    	root->right=r;
    	return r;
    	
    }
    if(infoinfo)
    stree(r,r->left,info);
    else
    stree(r,r->right,info);
    return root;
    

    }
    void print_tree(struct tree *r,int l)
    {
    int i;
    if(!r) return ;
    print_tree(r->right,l+1);
    for(i=0;iinfo);
    print_tree(r->left,l+1);

    }

    C / C++ / MFC help data-structures performance question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups