Search:

Type: Posts; User: redworker

Search: Search took 0.01 seconds.

  1. @Salem, this code seems to be working fine and...

    @Salem, this code seems to be working fine and got rid of most of the errors. I also set all global variables to 0/NULL too. It cleared the pointer related leaks and I will be able to fix rest.
    ...
  2. Ok, I was able to make some memory leaks go away...

    Ok, I was able to make some memory leaks go away by calling free on htable. How do I call free() on resluts?


    h_ptr new_element(char *s)
    {
    h_ptr result = (h_ptr) malloc(sizeof(h_rec));
    ...
  3. By didn't work I mean it didn't make any...

    By didn't work I mean it didn't make any difference with my memory leaks errors. I think I need to call free() on results as well to get rid of errors. Tried several things but it making error even...
  4. How does this look: void freeHash(htable) ...

    How does this look:


    void freeHash(htable)
    {
    if (!htable) return;
    for (int i=0; i<tsize; i++)
    free(htable[i]);
    free(htable);
    }
  5. So, I need to create a function that iterates...

    So, I need to create a function that iterates (for loop) through the list and then call free()? I will do some research on hash tables and will try if I can do it.

    Thanks for the help
  6. @grumpy Can't really redesign as I am doing an...

    @grumpy
    Can't really redesign as I am doing an exercise to detect and fix memory leaks. This code was all given and I just want to get rid of memory leaks to get some experience with memory...
  7. Yeah, I though I knew where should i call free()...

    Yeah, I though I knew where should i call free() but it didn't work. For example, what do you think when should I call free() on results variable. I tried it on several places and it made it worse....
  8. Where do I call free() to prevent memory leakes for this C program

    Hi,

    I believe I need to call free on Hash Table, List Elements and Unique words (htable, result etc). I am not sure where and how to call free as pointers are being used. Sorry program is big...
  9. Ah cant believe I did that mistake. Ok now I...

    Ah cant believe I did that mistake. Ok now I fixed the code but when I enter 20, it says factorial is -2102132736
    but when I enter lower number like 5, it gives me correct answer 120. Whats wrong...
  10. it gives me an error

    it gives me an error
  11. HOw to find factorial of a given number in C++ Language?

    Hi,

    I am working on a program that asks a user to enter a # between 1 to 50 and finds the factorial of that. It uses recursive function to find it.

    Here is what I got so far:


    ...
  12. Replies
    3
    Views
    2,799

    Finding Factorial in C language.

    Hi,

    I am working on a program that asks a user to enter a # between 1 to 50 and finds the factorial of that. It uses recursive function to find it.

    Here is what I got so far:


    include...
Results 1 to 12 of 12