Thread: tree node allocation

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    First, you need to pick whether you're using C or C++. The only thing in here that's particularly C++ is your use of cin and cout. Those are not allowed in C. If you want to use C++, you should post your question in the C++ forum. I'm going to pretend you mean to write C just to answer your question.

    As for the root1 unused, here's the line in question:
    Code:
    root1 = newnode1(root1);
    Before you can assign the result of newnode1() to root1, newnode1 must be called. When it's called, a copy of the current (uninitialized) value of root1 is passed in for use. The compiler is warning you about using the value unitialized. Your declaration line only sets root2 to NULL, the rest have random, garbage values in them. You need to initialize each one to NULL if that's what you want:
    Code:
    tree root = NULL;
    tree root1 = NULL;
    tree root2 = NULL;

  2. #2
    Registered User
    Join Date
    May 2011
    Posts
    44
    thanks , i got it. such a dumb mistake i made.
    sid

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Delete Binary Tree Node
    By matrixx333 in forum C Programming
    Replies: 4
    Last Post: 11-30-2009, 12:39 AM
  2. Getting the parent of a node in a binary tree
    By budala in forum C Programming
    Replies: 4
    Last Post: 09-18-2009, 12:36 PM
  3. Delete a node in a binary tree
    By alice in forum C Programming
    Replies: 2
    Last Post: 07-05-2004, 05:01 AM
  4. delete node for a binary tree
    By AmazingRando in forum C Programming
    Replies: 4
    Last Post: 10-27-2003, 10:45 PM

Tags for this Thread