Karel-Lodewijk's Profile User Rating: -----

Reputation: 449 Architect
Group:
Mentors
Active Posts:
853 (0.76 per day)
Joined:
17-March 11
Profile Views:
6,213
Last Active:
User is offline Apr 27 2012 04:22 PM
Currently:
Offline

Previous Fields

Country:
BE
OS Preference:
Linux
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
275
Expert In:
C/C++, Ruby
Icon   Karel-Lodewijk has not set their status

Posts I've Made

  1. In Topic: Searching a BST error

    Posted 22 Apr 2012

    strcpy(str[1],tree->b_word); will fail when tree is an invalid pointer or NULL pointer, so I would look in that direction,

    Do you ever call it on an a NULL node directly ?

    Do you initialize left and rigth to NULL when they are not set ?

    I also notice you don't return the results of your recursive calls.

    Basically when dealing with recursion you probablky want to to check your stop condition first, in more or less pseudocode:

    node__t *search_bst(node__t *tree,char targetword[50]) {
        if (tree == NULL) return NULL; //not found
        if equal
            return tree;
        else if smaller
            return search_bst(tree->left, targetword);
        else //larger
            return search_bst(tree->rigth, targetword);
    }
    
    

    But also in this code left and rigth must be explicitly set to NULL on creation when there is no left or rigth child, C/C++ will not do this automatically.
  2. In Topic: Manageability improvments

    Posted 22 Apr 2012

    Well you can see that the 3 connection classes look very similar.

    In my opinion it would be much better to seperate a connections from what it connects to and what is sends. So 1 connection class with a function connect that takes a parameter(s) that tells it what to connect to. And a send function that takes as a parameter what it should send.
  3. In Topic: syntax error

    Posted 22 Apr 2012

    for(current=tree;current!=NULL) should be for(current=tree;current!=NULL;). A for loop header cotnains 3 statements, they can be empty, but you do need to keep the ;.
  4. In Topic: Using functions trouble

    Posted 21 Apr 2012

    Well basically they are asking you to write two functions that could look something like this.

    string get_guess(string& letters_used) {
        //asks the player for a correct guess and return it
        //also update letters_used
    }
    
    bool check_guess(string word, string guess) {
        //Print relevant output, returns true if the guess is correct, otherwise false
    }
    
    


    The code that should go into these functions is basically all there. It's a restructuring excercise.

    The second step would then be to write the main loop using these 2 functions.

My Information

Member Title:
D.I.C Addict
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Full Name:
Karel-Lodewijk Verdonck

Contact Information

E-mail:
Click here to e-mail me

Comments

Page 1 of 1
  1. Photo

    raspinudo Icon

    31 May 2012 - 11:41
    Just wanted to say thanks for your C++11 Memory Management Tutorial, it was super helpful; hopefully I can try to use some of the new features in my side project this summer. I did have one question, you mention the 'C way' of allocating, 'malloc'; is there anytime in C++ where it would be better to use malloc instead of new?
  2. Photo

    general07z Icon

    18 Feb 2012 - 22:21
    Thanks a million lats. Keep it up.
    Best Regards and respect
  3. Photo

    Karel-Lodewijk Icon

    05 Feb 2012 - 09:52
    No, sorry, must be someone else.
  4. Photo

    Cyclopses Icon

    31 Jan 2012 - 05:05
    Former math teacher by any chance?
  5. Photo

    ishkabible Icon

    12 Oct 2011 - 18:38
    great job in C++, keep it up!
Page 1 of 1