Thread: i dont understand what i did wrong-allocate and Memory

  1. #16
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,791
    Code:
    void buildTree(node* head)
    {
        char character;
        node* pointNode = head;
    
        do {
            character = fgetc(fp); //getchar();
            character = tolower(character); //Turns a big letter into a small letter lib <ctype.h>
            if(character == EOF) {
                pointNode->count++;   // <------------ segfault is here
                return;
            }
    pointNode is somehow ending up being NULL, even though head != NULL. Weird. My guess is that you're causing a corruption somewhere (probably in . If I change that line to head->count++ the segfault goes away, but doesn't explain anything. Inspecting the "tree" in the function printWord() the majority of nodes are NULL so... I'm not sure where though

  2. #17
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,791
    Quote Originally Posted by thebesthere231 View Post
    Ok the argc i understand but why the second its not true. I allocated a adress at size of the longest word that i can print and build the max array foe the other words... but i have bigger problen that the code not working sugemanation fault
    Dealing with the strWord[levelTree] problem first (I changed the previously mentioned pointNode->count++ to head->count++ to get rid of the segfault just so I could run valgrind to ensure my sanity)

    Code:
    valgrind --tool=memcheck --leak-check=full ./test
    
    ==3694== Memcheck, a memory error detector
    ==3694== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==3694== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
    ==3694== Command: ./test
    ==3694== 
             1                                                     #### Program output
    ==3694== Invalid write of size 1
    ==3694==    at 0x4015E3: printWord (main.c:148)
    ==3694==    by 0x401670: printWord (main.c:155)
    ==3694==    by 0x401670: printWord (main.c:155)
    ==3694==    by 0x401670: printWord (main.c:155)
    ==3694==    by 0x401670: printWord (main.c:155)
    ==3694==    by 0x401670: printWord (main.c:155)
    ==3694==    by 0x40129C: main (main.c:41)
    ==3694==  Address 0x4dedb95 is 0 bytes after a block of size 5 alloc'd
    ==3694==    at 0x483880B: malloc (vg_replace_malloc.c:309)
    ==3694==    by 0x401242: main (main.c:36)
    ==3694== 
    ==3694== Invalid read of size 1
    ==3694==    at 0x483BBF4: strlen (vg_replace_strmem.c:461)
    ==3694==    by 0x4C71A1D: __vfprintf_internal (in /usr/lib64/libc-2.29.so)
    ==3694==    by 0x4C5C38E: printf (in /usr/lib64/libc-2.29.so)
    ==3694==    by 0x401605: printWord (main.c:149)
    ==3694==    by 0x401670: printWord (main.c:155)
    ==3694==    by 0x401670: printWord (main.c:155)
    ==3694==    by 0x401670: printWord (main.c:155)
    ==3694==    by 0x401670: printWord (main.c:155)
    ==3694==    by 0x401670: printWord (main.c:155)
    ==3694==    by 0x40129C: main (main.c:41)
    ==3694==  Address 0x4dedb95 is 0 bytes after a block of size 5 alloc'd
    ==3694==    at 0x483880B: malloc (vg_replace_malloc.c:309)
    ==3694==    by 0x401242: main (main.c:36)
    ==3694== 
    hello    1                                                     #### Program output
    world    1                                                     #### Program output
    The line numbers won't match up with yours because I added some lines.
    Lines 148 and 149 are
    Code:
    strWord[levelTree] = '\0';
    printf("%s\t %ld \n",strWord,nPointer->count);
    So it's certainly a problem, but not what's causing the segfault.

    Do you use linux? If so, install valgrind and use the command shown above (in purple). I want to make sure that I haven't changed something to introduce a different bug... I don't think I have, but who knows

  3. #18
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by Hodor View Post
    Code:
    void buildTree(node* head)
    {
        char character;
        node* pointNode = head;
    
        do {
            character = fgetc(fp); //getchar();
            character = tolower(character); //Turns a big letter into a small letter lib <ctype.h>
            if(character == EOF) {
                pointNode->count++;   // <------------ segfault is here
                return;
            }
    pointNode is somehow ending up being NULL, even though head != NULL. Weird. My guess is that you're causing a corruption somewhere (probably in . If I change that line to head->count++ the segfault goes away, but doesn't explain anything. Inspecting the "tree" in the function printWord() the majority of nodes are NULL so... I'm not sure where though
    You all do know that character should be a int or undefined things can happen, right?

    Edit: This line should be after the test for EOF!
    Code:
    character = tolower(character);
    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  4. #19
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,791
    Regarding the segfault...

    Code:
    $ valgrind --tool=memcheck --leak-check=full ./test 
    ==3753== Memcheck, a memory error detector
    ==3753== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==3753== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
    ==3753== Command: ./test
    ==3753== 
    ==3753== Invalid read of size 8
    ==3753==    at 0x40139F: buildTree (main.c:82)
    ==3753==    by 0x401221: main (main.c:34)
    ==3753==  Address 0x8 is not stack'd, malloc'd or (recently) free'd
    ==3753== 
    ==3753== 
    ==3753== Process terminating with default action of signal 11 (SIGSEGV): dumping core
    ==3753==  Access not within mapped region at address 0x8
    ==3753==    at 0x40139F: buildTree (main.c:82)
    ==3753==    by 0x401221: main (main.c:34)
    Line 82 is the previously mentioned pointNode->count++; line in buildTree. I don't really understand what's going on here because "head" is the correct value.

  5. #20
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,791
    Quote Originally Posted by stahta01 View Post
    You all do know that character should be a int or undefined things can happen, right?

    Edit: This line should be after the test for EOF!
    Code:
    character = tolower(character);
    Tim S.
    Thanks. I'm not sure how I missed those. But it still segfaults :/ pointNode is NULL when head != NULL. Maybe I need sleep. Edit: nevermind, I see it
    Last edited by Hodor; 01-19-2020 at 08:01 PM.

  6. #21
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,791
    @thebesthere231, make the changes suggested by @stahta01 and the changes I previously mentioned. Then also change the code in buildTree to

    Code:
    do {
            character = getchar();
            if(character == EOF) {
                if (pointNode)
                    pointNode->count++;
                return;
            }
            character = tolower(character); //Turns a big letter into a small letter lib <ctype.h>
    
            /* ... rest remains the same as before ... */
    and in main make this change
    Code:
        int biggestWordLength=bigWordLength(head, 0) + 1;
    I don't know if the logic is correct, but it produces the output I expect

    Code:
    ==4389== Command: ./test r
    ==4389== 
    world    1 
    hello    1 
    ==4389== 
    ==4389== HEAP SUMMARY:
    ==4389==     in use at exit: 0 bytes in 0 blocks
    ==4389==   total heap usage: 16 allocs, 16 frees, 80,846 bytes allocated
    ==4389== 
    ==4389== All heap blocks were freed -- no leaks are possible
    ==4389== 
    ==4389== For lists of detected and suppressed errors, rerun with: -s
    ==4389== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
    Now for some sleep :/
    Last edited by Hodor; 01-19-2020 at 08:13 PM.

  7. #22
    Registered User
    Join Date
    Nov 2019
    Posts
    12
    Quote Originally Posted by Hodor View Post
    @thebesthere231, make the changes suggested by @stahta01 and the changes I previously mentioned. Then also change the code in buildTree to

    Code:
    do {
            character = getchar();
            if(character == EOF) {
                if (pointNode)
                    pointNode->count++;
                return;
            }
            character = tolower(character); //Turns a big letter into a small letter lib <ctype.h>
    
            /* ... rest remains the same as before ... */
    and in main make this change
    Code:
        int biggestWordLength=bigWordLength(head, 0) + 1;
    I don't know if the logic is correct, but it produces the output I expect

    Code:
    ==4389== Command: ./test r
    ==4389== 
    world    1 
    hello    1 
    ==4389== 
    ==4389== HEAP SUMMARY:
    ==4389==     in use at exit: 0 bytes in 0 blocks
    ==4389==   total heap usage: 16 allocs, 16 frees, 80,846 bytes allocated
    ==4389== 
    ==4389== All heap blocks were freed -- no leaks are possible
    ==4389== 
    ==4389== For lists of detected and suppressed errors, rerun with: -s
    ==4389== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
    Now for some sleep :/
    of so i changes all u write up of quaote and the argc . what i need to change too that i missed ?
    and still i have problem like i free more that i have ..

    double free or corruption (!prev)
    Aborted (core dumped)

  8. #23
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,791
    Quote Originally Posted by thebesthere231 View Post
    of so i changes all u write up of quaote and the argc . what i need to change too that i missed ?
    and still i have problem like i free more that i have ..

    double free or corruption (!prev)
    Aborted (core dumped)
    I don't know. I didn't get any double frees. Did you change anything else in the meantime? I'm still not convinced that it's creating a tree structure like you want it to but that's something else entirely...

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <ctype.h>
    #include <stdlib.h>
    
    #define NUM_LETTERS 26
    
    typedef struct node {
        char letter;
        long unsigned int count;
        struct node* children[NUM_LETTERS];
    } node;
    
    int isCharLeagal(int c);
    node* newNode(void);
    void buildTree(node* head);
    node* addword(node* head, node* pointNode, int character);
    int bigWordLength(node* n, int counter);
    void freeLevelsOnTree(node* head);
    void printWord(node* head,char strWord[], int levelTree);
    void printWordReverse(node* head,char strWord[], int levelTree);
    
    FILE *fp;                                                    /*** Delete this; I had it just for testing ***/
    
    int main(int argc, char* argv[])
    {
        fp = fopen("input.txt", "r");         /*** Delete this; I had it just for testing ***/
        if (!fp) {                                    /*** Delete this; I had it just for testing ***/
            perror("fopen");                    /*** Delete this; I had it just for testing ***/
        }                                             /*** Delete this; I had it just for testing ***/
    
        char* r = "r";
        node* head = newNode();
        buildTree(head);
        int biggestWordLength=bigWordLength(head, 0);
        char* word = (char*)malloc(biggestWordLength + 1);
    
        if( ((argc>1) && strcmp(argv[1],r)==0) ) {
            printWordReverse(head,word,0);
        } else {
            printWord(head,word,0);
        }
    
        free(word);
        freeLevelsOnTree(head);
    
        fclose(fp);             /*** Delete this; I had it just for testing ***/
    
        return 0;
    }
    
    node* newNode(void)
    {
        node* n = NULL;
        n = (node*)malloc(sizeof(node));
        if (n == NULL) {
            printf("error-malloc not allocate memory");
            return NULL;
        }
        n->count = 0;
        int i;
        for (i = 0; i < NUM_LETTERS; i++) {
            n->children[i] = NULL;
        }
        return n;
    }
    
    void buildTree(node* head)
    {
        int character;
        node* pointNode = head;
    
        if (!pointNode) {
            printf("No point node\n");
            return;
        }
    
        do {
            character = fgetc(fp); //getchar();                /*** Change back to character = getchar() ***/
            if(character == EOF) {
                if (pointNode)
                    pointNode->count++;
                return;
            }
            character = tolower(character); //Turns a big letter into a small letter lib <ctype.h>
    // if(!( character>='a' && character<='z') )
    // {continue;}
            if (!isCharLeagal(character)) continue;
            if (character == '\n' || character == ' ' || character == '\t') {
                if ( (pointNode != NULL) && (pointNode != head) ) {
                    pointNode->count++;
                    pointNode= NULL;
                }
                continue;
            }
            if(pointNode ==NULL) {
                pointNode = head;
            }
            pointNode = addword(head, pointNode, character);
        } while(character!=EOF);
    }
    
    node* addword(node* head, node* pointNode,int character)
    {
        int i = (((int)character)-((int)'a')) ; //calculate the place of the index
        if( (pointNode->children[i]) == NULL ) {
            pointNode->children[i] = newNode();
            pointNode->children[i]->letter = character;
        }
        pointNode = pointNode->children[i];
        return pointNode;
    }
    
    void freeLevelsOnTree(node* head)
    {
        node* nPointer = head;
    
        for (size_t i=0; i<NUM_LETTERS; i++) {
            if(nPointer->children[i] !=NULL) {
                freeLevelsOnTree(nPointer->children[i]);
            }
        }
        free(nPointer);
    }
    
    int bigWordLength(node* n, int counter)
    {
        int i;
        int length = counter;
    
        for(i = 0; i < NUM_LETTERS; i++) {
            if(n->children[i]!=NULL) {
                int length2 = bigWordLength(n->children[i], counter + 1);
                if(length2 > length) {
                    length = length2;
                }
            }
        }
        return length;
    }
    
    void printWord(node* head, char strWord[], int levelTree)
    {
        node* nPointer = head;
        if (nPointer == NULL) {
            return;
        }
        if (nPointer->count > 0) {
            strWord[levelTree] = '\0';
            printf("%s\t %ld \n",strWord,nPointer->count);
        }
        int i;
        for(i = 0; i < NUM_LETTERS; i++) {
            if(nPointer->children[i] != NULL) {
                strWord[levelTree]=nPointer->children[i]->letter;
                printWord(nPointer->children[i], strWord,levelTree + 1);
            }
        }
    }
    
    void printWordReverse(node* head, char strWord[], int levelTree)
    {
        node* nPointer2 = head;
        if(nPointer2 == NULL) {
            return;
        }
        if(nPointer2->count > 0) {
            strWord[levelTree] = '\0';
            printf("%s\t %ld \n",strWord,nPointer2->count);
        }
        int i;
        for(i = NUM_LETTERS-1; i >= 0; i--) {
            if(nPointer2->children[i]!= NULL) {
                strWord[levelTree] = nPointer2->children[i]->letter;
                printWordReverse(nPointer2->children[i], strWord, levelTree + 1);
            }
        }
    }
    
    int isCharLeagal(int c)
    {
        if((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c == '\n' || c == ' ' || c == '\t')) {
            return 1;
        }
        return 0;
    }
    Code:
    $ valgrind --tool=memcheck --leak-check=full ./test 
    ==1850== Memcheck, a memory error detector
    ==1850== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==1850== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
    ==1850== Command: ./test
    ==1850== 
    another  1 
    hello    1 
    is       1 
    sentence         1 
    this     1 
    world    1 
    ==1850== 
    ==1850== HEAP SUMMARY:
    ==1850==     in use at exit: 0 bytes in 0 blocks
    ==1850==   total heap usage: 37 allocs, 37 frees, 85,553 bytes allocated
    ==1850== 
    ==1850== All heap blocks were freed -- no leaks are possible
    Last edited by Hodor; 01-20-2020 at 04:58 AM.

  9. #24
    Registered User
    Join Date
    Nov 2019
    Posts
    12
    Quote Originally Posted by Hodor View Post
    I don't know. I didn't get any double frees. Did you change anything else in the meantime? I'm still not convinced that it's creating a tree structure like you want it to but that's something else entirely...

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <ctype.h>
    #include <stdlib.h>
    
    #define NUM_LETTERS 26
    
    typedef struct node {
        char letter;
        long unsigned int count;
        struct node* children[NUM_LETTERS];
    } node;
    
    int isCharLeagal(int c);
    node* newNode(void);
    void buildTree(node* head);
    node* addword(node* head, node* pointNode, int character);
    int bigWordLength(node* n, int counter);
    void freeLevelsOnTree(node* head);
    void printWord(node* head,char strWord[], int levelTree);
    void printWordReverse(node* head,char strWord[], int levelTree);
    
    FILE *fp;                                                    /*** Delete this; I had it just for testing ***/
    
    int main(int argc, char* argv[])
    {
        fp = fopen("input.txt", "r");         /*** Delete this; I had it just for testing ***/
        if (!fp) {                                    /*** Delete this; I had it just for testing ***/
            perror("fopen");                    /*** Delete this; I had it just for testing ***/
        }                                             /*** Delete this; I had it just for testing ***/
    
        char* r = "r";
        node* head = newNode();
        buildTree(head);
        int biggestWordLength=bigWordLength(head, 0);
        char* word = (char*)malloc(biggestWordLength + 1);
    
        if( ((argc>1) && strcmp(argv[1],r)==0) ) {
            printWordReverse(head,word,0);
        } else {
            printWord(head,word,0);
        }
    
        free(word);
        freeLevelsOnTree(head);
    
        fclose(fp);             /*** Delete this; I had it just for testing ***/
    
        return 0;
    }
    
    node* newNode(void)
    {
        node* n = NULL;
        n = (node*)malloc(sizeof(node));
        if (n == NULL) {
            printf("error-malloc not allocate memory");
            return NULL;
        }
        n->count = 0;
        int i;
        for (i = 0; i < NUM_LETTERS; i++) {
            n->children[i] = NULL;
        }
        return n;
    }
    
    void buildTree(node* head)
    {
        int character;
        node* pointNode = head;
    
        if (!pointNode) {
            printf("No point node\n");
            return;
        }
    
        do {
            character = fgetc(fp); //getchar();                /*** Change back to character = getchar() ***/
            if(character == EOF) {
                if (pointNode)
                    pointNode->count++;
                return;
            }
            character = tolower(character); //Turns a big letter into a small letter lib <ctype.h>
    // if(!( character>='a' && character<='z') )
    // {continue;}
            if (!isCharLeagal(character)) continue;
            if (character == '\n' || character == ' ' || character == '\t') {
                if ( (pointNode != NULL) && (pointNode != head) ) {
                    pointNode->count++;
                    pointNode= NULL;
                }
                continue;
            }
            if(pointNode ==NULL) {
                pointNode = head;
            }
            pointNode = addword(head, pointNode, character);
        } while(character!=EOF);
    }
    
    node* addword(node* head, node* pointNode,int character)
    {
        int i = (((int)character)-((int)'a')) ; //calculate the place of the index
        if( (pointNode->children[i]) == NULL ) {
            pointNode->children[i] = newNode();
            pointNode->children[i]->letter = character;
        }
        pointNode = pointNode->children[i];
        return pointNode;
    }
    
    void freeLevelsOnTree(node* head)
    {
        node* nPointer = head;
    
        for (size_t i=0; i<NUM_LETTERS; i++) {
            if(nPointer->children[i] !=NULL) {
                freeLevelsOnTree(nPointer->children[i]);
            }
        }
        free(nPointer);
    }
    
    int bigWordLength(node* n, int counter)
    {
        int i;
        int length = counter;
    
        for(i = 0; i < NUM_LETTERS; i++) {
            if(n->children[i]!=NULL) {
                int length2 = bigWordLength(n->children[i], counter + 1);
                if(length2 > length) {
                    length = length2;
                }
            }
        }
        return length;
    }
    
    void printWord(node* head, char strWord[], int levelTree)
    {
        node* nPointer = head;
        if (nPointer == NULL) {
            return;
        }
        if (nPointer->count > 0) {
            strWord[levelTree] = '\0';
            printf("%s\t %ld \n",strWord,nPointer->count);
        }
        int i;
        for(i = 0; i < NUM_LETTERS; i++) {
            if(nPointer->children[i] != NULL) {
                strWord[levelTree]=nPointer->children[i]->letter;
                printWord(nPointer->children[i], strWord,levelTree + 1);
            }
        }
    }
    
    void printWordReverse(node* head, char strWord[], int levelTree)
    {
        node* nPointer2 = head;
        if(nPointer2 == NULL) {
            return;
        }
        if(nPointer2->count > 0) {
            strWord[levelTree] = '\0';
            printf("%s\t %ld \n",strWord,nPointer2->count);
        }
        int i;
        for(i = NUM_LETTERS-1; i >= 0; i--) {
            if(nPointer2->children[i]!= NULL) {
                strWord[levelTree] = nPointer2->children[i]->letter;
                printWordReverse(nPointer2->children[i], strWord, levelTree + 1);
            }
        }
    }
    
    int isCharLeagal(int c)
    {
        if((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c == '\n' || c == ' ' || c == '\t')) {
            return 1;
        }
        return 0;
    }
    Code:
    $ valgrind --tool=memcheck --leak-check=full ./test 
    ==1850== Memcheck, a memory error detector
    ==1850== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==1850== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
    ==1850== Command: ./test
    ==1850== 
    another  1 
    hello    1 
    is       1 
    sentence         1 
    this     1 
    world    1 
    ==1850== 
    ==1850== HEAP SUMMARY:
    ==1850==     in use at exit: 0 bytes in 0 blocks
    ==1850==   total heap usage: 37 allocs, 37 frees, 85,553 bytes allocated
    ==1850== 
    ==1850== All heap blocks were freed -- no leaks are possible
    int isCharLeagal(int c);
    node* newNode(void);why u changed to int and why u write void ? i
    Is it okay like it wasn't?
    Because it works too





    and ok so somehow i fix this problem !
    the last problem that i said was on the freelevels function
    but now i get a diffrent isuue
    when i put input like

    all alla alladin

    i need to do 2 options
    1- when i type on console ./test<input this should print me and that ok -the function is printword
    all
    alla
    alladin

    2-but when i type on console ./test r<input this should print me and that ok -the function is printword(to print all the words In lexicographic order from large to small (that why thr "r" on argv-reverse)
    this should print me
    alladin
    alla
    all

    And I probably have a problem with the function printWordReverse.

    so can u help me with this?

    i think because end of word on the node the count will be >0 and it print me that and continue to add letters and print too . And I have to print the from the big word to the small
    so i need to do more Condition in that function something like>

    Code:
    if(nPointer2->count > 0)
      {
         for(i = NUM_LETTERS-1; i >= 0; i--)
          {
            if(nPointer2->children[i]!= NULL)
             {

  10. #25
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,791
    Quote Originally Posted by thebesthere231 View Post
    int isCharLeagal(int c);
    node* newNode(void);why u changed to int and why u write void ? i
    Is it okay like it wasn't?
    Because it works too
    I changed to int because all the character functions like isspace() and isalpha() expect an int -- not to mention that getchar returns an int. You can probably get away without changing those functions I changed from needing an int and leaving them as needing a char, but I was doing you a favour because they can be simplified if you pass the character as an int.


    Quote Originally Posted by thebesthere231 View Post
    and ok so somehow i fix this problem !
    the last problem that i said was on the freelevels function
    You could at least tell us what you changed and what the problem was.

    Quote Originally Posted by thebesthere231 View Post
    but now i get a diffrent isuue
    when i put input like

    all alla alladin

    i need to do 2 options
    1- when i type on console ./test<input this should print me and that ok -the function is printword
    all
    alla
    alladin

    2-but when i type on console ./test r<input this should print me and that ok -the function is printword(to print all the words In lexicographic order from large to small (that why thr "r" on argv-reverse)
    this should print me
    alladin
    alla
    all

    And I probably have a problem with the function printWordReverse.

    so can u help me with this?
    I don't know. I don't think it's creating a tree like you think it is. What are your thoughts?

  11. #26
    Registered User
    Join Date
    Nov 2019
    Posts
    12
    Quote Originally Posted by Hodor View Post
    I changed to int because all the character functions like isspace() and isalpha() expect an int -- not to mention that getchar returns an int. You can probably get away without changing those functions I changed from needing an int and leaving them as needing a char, but I was doing you a favour because they can be simplified if you pass the character as an int.




    You could at least tell us what you changed and what the problem was.



    I don't know. I don't think it's creating a tree like you think it is. What are your thoughts?

    i did that , success finally ! thank you very much for the help !
    thank u!

  12. #27
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,791
    Quote Originally Posted by thebesthere231 View Post
    i did that , success finally ! thank you very much for the help !
    thank u!
    Some feedback would be nice. Anyway, good to hear you were successful

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2012, 04:28 AM
  2. Allocate memory inside allocated memory block?
    By Heidi_Nayak in forum C Programming
    Replies: 14
    Last Post: 04-15-2009, 04:19 PM
  3. Replies: 13
    Last Post: 11-14-2008, 03:52 PM
  4. New to c++/c and dont understand the use of memory pointers
    By (Slith++) in forum C++ Programming
    Replies: 6
    Last Post: 12-19-2005, 05:30 PM
  5. help......i dont understand what i am doing wrong?
    By Grifftt in forum C Programming
    Replies: 2
    Last Post: 10-18-2002, 11:37 PM

Tags for this Thread