Thread: strange behaviour

  1. #16
    Registered User
    Join Date
    Jul 2012
    Location
    Australia
    Posts
    242
    Quote Originally Posted by std10093 View Post
    Looking again at the post i show that
    cfanatic does not write void when the function has no parameters at all.(e.g. line 16 at post #1)

    I am bit of confused here.What should we do?Use void or not?
    Read the bottom of post #8 in this thread.

    every C learner's nightmare: linked lists

    EDIT: My function options() will have some parameters, but I don't know what the parameters are yet, that's why I left it blank. I suppose I should use "void" in the parameter list, but I was just lazy.
    Last edited by cfanatic; 09-28-2012 at 06:29 PM.
    IDE: Code::Blocks | Compiler Suite for Windows: TDM-GCC (MingW, gdb)

  2. #17
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    I had read that specific post but i couldn't remember it now.Thank you very much...and sorry for asking in your post my question

    The edit just answered the question i would make

    PS->linked list are not nightmares,linked lists are super!!!

  3. #18
    Registered User
    Join Date
    Jul 2012
    Location
    Australia
    Posts
    242
    For some reason, getword() is returning only every second word. I think it is because of the space behind every word.

    text/temp.txt = "How now brown cow. A cow has four brown legs."

    output:
    Code:
    How brown  cow four legs (null)
    Code:
    // spellcheck.c - checks spelling of a text file against a dictionary file
    // 5 functions: copyfile(), getword(), spellcheck(), options(), editfile()
    
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    #define BUFFERSIZE 4096
    #define FILENAME_LENGTH 40
    #define STRING_LENGTH 300 // length of string read by fgets() from file
    #define WORD_LENGTH 40
    
    void copyfile (FILE *file, FILE *tempfile);
    char *getword(FILE *tempfile);
    //void spellcheck (struct word *word_to_check);
    void options();
    void editfile();
    
    int main(void)
    {
        FILE *file, *dictionary, *tempfile;
        char *word;
    
        copyfile(file, tempfile);
        tempfile = fopen("temp.txt", "r");
        dictionary = fopen("dictionary.txt", "r");
        word = malloc(WORD_LENGTH * sizeof(char));
    
        do
        {
            word = getword(tempfile);
            printf("%s ",word);
    //        spellcheck(word_to_check.word);
        //option();
        //edit();
        } while (getword(tempfile) != NULL);
    
        return 0;
    
    }
    
    // copy original file to tempfile for reading so that original file can be opened for writing(editing)
    void copyfile(FILE *file, FILE *tempfile)
    {
        size_t c;
        char buffer[BUFFERSIZE];
    
        file = fopen("test.txt", "r");
        tempfile = fopen("temp.txt", "w");
    
        while((c = fread(buffer, 1, BUFFERSIZE, file)) > 0)
        {
            fwrite(buffer, 1, c, tempfile);
        }
        fclose(file);
        fclose(tempfile);
    }
    
    char *getword(FILE *tempfile)
    {
    
        static char word[WORD_LENGTH]; // static to retain value of word
        int ch;
        int ctr = 0;
    
        while((ch = fgetc(tempfile)) != EOF)
        {
            if((ch != ' ') && (ch != '.') && (ch != '-') && (ch != '!') && (ch != '(') && (ch != ')') && (ch != ':') && (ch != ';') && (ch != '\n'))
            {
                word[ctr] = ch;
                ctr++;
                continue;
            }
            else
            {
                word[ctr] = '\0'; // if ch is space or punctuation, add terminator to create string
                return word; // return pointer to main()
            }
        }
        return NULL; // flag that EOF has been reached
    }
    
    //void spellcheck (struct word *word_to_check)
    //{
    //
    //}
    So I tried some things to move the position indicator past the space, but they don't work.

    Code:
    while((ch = fgetc(tempfile)) != EOF)
        {
            if((ch != ' ') && (ch != '.') && (ch != '-') && (ch != '!') && (ch != '(') && (ch != ')') && (ch != ':') && (ch != ';') && (ch != '\n'))
            {
                word[ctr] = ch;
                ctr++;
                continue;
            }
            else
            {
                word[ctr] = '\0'; // if ch is space or punctuation, add terminator to create string
                 ch1 = fgetc(tempfile); // get space character so position is at start of next word
                return word; // return pointer to main()
            }
        }
    Code:
    while((ch = fgetc(tempfile)) != EOF)
        {
            if((ch != ' ') && (ch != '.') && (ch != '-') && (ch != '!') && (ch != '(') && (ch != ')') && (ch != ':') && (ch != ';') && (ch != '\n'))
            {
                word[ctr] = ch;
                ctr++;
                continue;
            }
            else
            {
                word[ctr] = '\0'; // if ch is space or punctuation, add terminator to create string
                fseek(tempfile, ctr + 1, SEEK_SET); // seek position at start of next word
                return word; // return pointer to main()
            }
        }
    IDE: Code::Blocks | Compiler Suite for Windows: TDM-GCC (MingW, gdb)

  4. #19
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    I replaced this
    Code:
    if((ch != ' ') && (ch != '.') && (ch != '-') && (ch != '!') && (ch != '(') && (ch != ')') && (ch != ':') && (ch != ';') && (ch != '\n'))
    to this
    Code:
    if( (ch != '-') && (ch != '!') && (ch != '(') && (ch != ')') && (ch != ':') && (ch != ';') && (ch != '\n'))
    and i got the output
    Code:
    How now brown cow. A cow has four brown legs.
    Hope this helps

  5. #20
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Quote Originally Posted by std10093 View Post
    I replaced this
    Code:
    if((ch != ' ') && (ch != '.') && (ch != '-') && (ch != '!') && (ch != '(') && (ch != ')') && (ch != ':') && (ch != ';') && (ch != '\n'))
    to this
    Code:
    if( (ch != '-') && (ch != '!') && (ch != '(') && (ch != ')') && (ch != ':') && (ch != ';') && (ch != '\n'))
    Hope this helps
    That's probably not what cfanatic wants:
    Code:
    $ gdb -q ./test
    Reading symbols from test...done.
    (gdb) b 32
    Breakpoint 1 at 0x80485cb: file test.c, line 32.
    (gdb) r
    Starting program: test 
    
    Breakpoint 1, main () at test.c:32
    32            printf("%s ",word);
    (gdb) l 30,34
    30        {
    31            word = getword(tempfile);
    32            printf("%s ",word);
    33    //        spellcheck(word_to_check.word);
    34        //option();
    (gdb) p word
    $1 = 0x804a060 "How now brown cow. A cow has four brown legs."
    As you can see your changes causes getword() to read the whole line into word.

    The problem lies here:
    Code:
    int main(void)
    {
    ...
        do
        {
            word = getword(tempfile);         // first call to getword() storing the first word into "word"
            printf("%s ",word);
            //spellcheck(word_to_check.word);
            //option();
            //edit();
        } while (getword(tempfile) != NULL);       // second call to getword() throwing away its return value
    Because cfanatic calls getword() twice in each iteration only every second word is stored in "word".

    Bye, Andreas

  6. #21
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Whoa there...
    I suggest changing this sort of thing:
    Code:
    if((ch != ' ') && (ch != '.') && (ch != '-') && (ch != '!') && (ch != '(') && (ch != ')') && (ch != ':') && (ch != ';') && (ch != '\n'))
    to something like this
    Code:
    char buf[2] = {ch};
    if (strpbrk(buf, " .-!():;\n") == NULL)
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  7. #22
    Registered User
    Join Date
    Jul 2012
    Location
    Australia
    Posts
    242
    Here is a rough idea of what the code will eventually look like. I can't get the algorithm right for comparing each word in the text file with every word in the dictionary file(which is made up of one word per line, 100K words in total). But I am working on it.

    Code:
    // spellcheck.c - checks spelling of a text file against a dictionary file
    // 5 functions: copyfile(), getword(), spellcheck(), options(), editfile()
    
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    #define BUFFERSIZE 4096
    #define FILENAME_LENGTH 40
    #define STRING_LENGTH 300 // length of string read by fgets() from file
    #define WORD_LENGTH 40
    
    void copyfile (FILE *file, FILE *tempfile);
    char *getword(FILE *tempfile);
    char *spellcheck (char *word, FILE *dictionary);
    int  options(char *errorword, FILE *dictionary);
    void editfile();
    
    int main(void)
    {
        FILE *file, *dictionary, *tempfile;
        char *word, *errorword;
    
        copyfile(file, tempfile);
        tempfile = fopen("temp.txt", "r");
        dictionary = fopen("dictionary.txt", "r");
        word = malloc(WORD_LENGTH * sizeof(char));
        errorword = malloc(WORD_LENGTH * sizeof(char));
    
        do
        {
            word = getword(tempfile);
            if((errorword = spellcheck(word, dictionary)) == NULL)
            {
                puts("Spellcheck complete");
            }
            else
            {
                options(errorword, dictionary);
                //editfile();
            }
        } while (getword(tempfile) != NULL);
    
        return 0;
    }
    
    // copy original file to tempfile for reading so that original file can be opened for writing(editing)
    void copyfile(FILE *file, FILE *tempfile)
    {
        size_t c;
        char buffer[BUFFERSIZE];
    
        file = fopen("test.txt", "r");
        tempfile = fopen("temp.txt", "w");
    
        while((c = fread(buffer, 1, BUFFERSIZE, file)) > 0)
        {
            fwrite(buffer, 1, c, tempfile);
        }
        fclose(file);
        fclose(tempfile);
    }
    
    char *getword(FILE *tempfile)
    {
    
        static char word[WORD_LENGTH]; // static to retain value of word
        int ch;
        int ctr = 0;
    
        while((ch = fgetc(tempfile)) != EOF)
        {
            if((ch != ' ') && (ch != '.') && (ch != '-') && (ch != '!') && (ch != '(') && (ch != ')') && (ch != ':') && (ch != ';') && (ch != '\n'))
            {
                word[ctr] = ch;
                ctr++;
                continue;
            }
            else
            {
                word[ctr] = '\0'; // if ch is space or punctuation, add terminator to create string
                return word;
            }
        }
        return NULL; // flag that EOF has been reached
    }
    
    char *spellcheck(char *word, FILE *dictionary)
    {
        int x, ch, flag, cmpr, ctr = 0;
        char buffer[BUFFERSIZE];
        char word_in_dict[WORD_LENGTH];
    
        while((ch = fgetc(dictionary)) != EOF)
        {
            if((ch != '\n'))
            {
                word_in_dict[ctr] = ch;
                ctr++;
                continue;
            }
            else
            {
                word_in_dict[ctr] = '\0'; // add terminator to make string
    
                if((cmpr = strcmp(word, word_in_dict)) == 0) // compare word to dictionary word
                {
    
                    return NULL; // match found, nothing further needs doing
                }
                else
                {
                    continue; // keep comparing word to more dictionary words
                }
            }
        }
        return word; // if no matches between word and any dictionary words, return word to main()
    }
    
    int  options(char *errorword, FILE *dictionary)
    {
        int x, ch;
    
        do
        {
            printf("%s: no match found\n", errorword);
            printf("Alternative words: \n");
            printf("0 to quit \n");
        } while(scanf("%d", &x) > 6);
    
        if(x == 0)
        {
            exit(1);
        }
    }
    
    void editfile()
    {
    
    }
    IDE: Code::Blocks | Compiler Suite for Windows: TDM-GCC (MingW, gdb)

  8. #23
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    cfanatic i suggest you listen to what Andreas said and call only once the getword() function in function main in your do...while loop
    Then when you check in the dictionary why you use this
    Code:
                else
                {
                    continue; // keep comparing word to more dictionary words
                }
    i do not think that it saves you time,because it is already in the end of the loop

    As for your problem,you have to be more specific

  9. #24
    Registered User
    Join Date
    Jul 2012
    Location
    Australia
    Posts
    242
    Quote Originally Posted by iMalc View Post
    Whoa there...
    I suggest changing this sort of thing:
    Code:
    if((ch != ' ') && (ch != '.') && (ch != '-') && (ch != '!') && (ch != '(') && (ch != ')') && (ch != ':') && (ch != ';') && (ch != '\n'))
    to something like this
    Code:
    char buf[2] = {ch};
    if (strpbrk(buf, " .-!():;\n") == NULL)
    Sounds like a useful function, but I am going to stick with what I know for now.
    IDE: Code::Blocks | Compiler Suite for Windows: TDM-GCC (MingW, gdb)

  10. #25
    Registered User
    Join Date
    Jul 2012
    Location
    Australia
    Posts
    242
    I don't know why the program doesn't just exit with "Spellcheck complete". The words should have been detected in the dictionary file.

    test.txt = "hello world."

    dictionary.txt
    Code:
    how 
    now
    hello 
    brown
    cow
    world
    output
    Code:
    hello: no match found
    world: no match found
    : no match found
    Code:
    // spellcheck.c - checks spelling of a text file against a dictionary file
    // 5 functions: copyfile(), getword(), spellcheck(), options(), editfile()
    
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    #define BUFFERSIZE 4096
    #define FILENAME_LENGTH 40
    #define STRING_LENGTH 300 // length of string read by fgets() from file
    #define WORD_LENGTH 40
    
    void copyfile (FILE *file, FILE *tempfile);
    char *getword(FILE *tempfile);
    char *spellcheck (char *word, FILE *dictionary);
    int  options(char *errorword, FILE *dictionary);
    void editfile();
    
    int main(void)
    {
        FILE *file, *dictionary, *tempfile;
        char *word, *errorword;
    
        copyfile(file, tempfile);
        tempfile = fopen("temp.txt", "r");
        dictionary = fopen("dictionary.txt", "r");
        word = malloc(WORD_LENGTH * sizeof(char));
        errorword = malloc(WORD_LENGTH * sizeof(char));
        word = getword(tempfile);
    
        do
        {
            if(spellcheck(word, dictionary) == NULL)
            {
                puts("Spellcheck complete");
                exit(1);
            }
            else
            {
                errorword = spellcheck(word, dictionary);
                options(errorword, dictionary);
                //editfile();
            }
        } while (getword(tempfile) != NULL);
    
        return 0;
    }
    
    // copy original file to tempfile for reading so that original file can be opened for writing(editing)
    void copyfile(FILE *file, FILE *tempfile)
    {
        size_t c;
        char buffer[BUFFERSIZE];
    
        file = fopen("test.txt", "r");
        tempfile = fopen("temp.txt", "w");
    
        while((c = fread(buffer, 1, BUFFERSIZE, file)) > 0)
        {
            fwrite(buffer, 1, c, tempfile);
        }
        fclose(file);
        fclose(tempfile);
    }
    
    char *getword(FILE *tempfile)
    {
    
        static char word[WORD_LENGTH]; // static to retain value of word
        int ch;
        int ctr = 0;
    
        while((ch = fgetc(tempfile)) != EOF)
        {
            if((ch != ' ') && (ch != '.') && (ch != '-') && (ch != '!') && (ch != '(') && (ch != ')') && (ch != ':') && (ch != ';') && (ch != '\n'))
            {
                word[ctr] = ch;
                ctr++;
                continue;
            }
            else
            {
                word[ctr] = '\0'; // if ch is space or punctuation, add terminator to create string
                return word;
            }
        }
        return NULL; // flag that EOF has been reached
    }
    
    char *spellcheck(char *word, FILE *dictionary)
    {
        int x, ch, flag, cmpr, ctr = 0;
        char buffer[BUFFERSIZE];
        char word_in_dict[WORD_LENGTH];
    
        while((ch = fgetc(dictionary)) != EOF)
        {
            if((ch != '\n'))
            {
                word_in_dict[ctr] = ch;
                ctr++;
                continue;
            }
            else
            {
                word_in_dict[ctr] = '\0'; // add terminator to make string
    
                if((cmpr = strcmp(word, word_in_dict)) == 0) // compare word to dictionary word
                {
                    return NULL; // match found, nothing further needs doing
                }
                ctr = 0; // reset array position to accept new word
            }
            return word; // if no matches between word and any dictionary words, return word to main()
        }
    }
    
    int  options(char *errorword, FILE *dictionary)
    {
        int x, ch;
    
    //    do
    //    {
            printf("%s: no match found\n", errorword);
    //        printf("Alternative words: \n");
    //        printf("0 to quit \n");
    //    } while(scanf("%d", &x) > 6);
    //
    //    if(x == 0)
    //    {
    //        exit(1);
    //    }
    }
    
    void editfile()
    {
    
    }
    IDE: Code::Blocks | Compiler Suite for Windows: TDM-GCC (MingW, gdb)

  11. #26
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Mark i have to say these
    • I know you are aware of the fact that the .txt files are already created before you run the code,but it would be nice to do an error check when opening the files,otherwise you will receive a segmentation fault if there are not created.
    • In function spellcheck i do not get why this line
      Code:
       return word; // if no matches between word and any dictionary words, return word to main()
      is inside the loop.Maybe there is a reason for that.
    • Why the comparison fails?Because you compare <hello> with <hello > for example.Do not store the whitespaces (or tabs)
      This is for no storing whitespaces
      Code:
      if(ch!=' ')
      {
            word_in_dict[ctr] = ch;
            ctr++;
      }
    • Also you have exit(1) in main loop,so when the code checks for the first word -> hello and finds a match ,it won't continue with the other words

  12. #27
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    The spellcheck() function only gets the next word in the dictionary and compares it with the next word in the test file. I know because I made my own dictionary. If "hello" and "world" were the first words encountered, spellcheck went fine, otherwise, it didn't.

  13. #28
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    In main, you're storing the address of some malloc'ed space in word, but then you overwrite that address (leaking the memory) with the return value of getword. Essentially the same thing happens to errorword. You seem to have a real misunderstanding here.


    spellcheck reads through the dictionary file. It's called multiple times, but I don't see the dictionary file being reset (or closed/reopened) anywhere.



    There's no reason to pass file and tempfile to copyfile since copyfile only uses them as local variables (i.e., it does not use their current values as for a normal function parameter). Just declare them in copyfile. Actually, copyfile would be a useful function if you declared it like this:
    Code:
    int copyfile(const char *from, const char *to) {
        FILE *ffrom, *fto;
        ffrom = fopen(from, "r");
        if (!ffrom) return 1;
        // ...
        return 0; // 0 for no error
    }


    Instead of
    Code:
    if((ch != ' ') && (ch != '.') && (ch != '-') && (ch != '!') && (ch != '(') && (ch != ')') && (ch != ':') && (ch != ';') && (ch != '\n'))
    you can use
    Code:
    if (strchr(" .-!():;\n", ch) == NULL) {
        word[ctr] = ch;
        ctr++;
        // get rid of the useless continue
    }
    else
    //...
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  14. #29
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    cfanatic, I think it's time for you to learn to use a debugger. You would have found the problem probably in less than 5 minutes yourself.

    Here is one possible session. I'm using gdb here but you can choose any debugger you like, even with fancy GUI :-):
    Code:
    $ gdb -q ./test
    Reading symbols from test...done.
    (gdb) b spellcheck 
    Breakpoint 1 at 0x8048889: file test.c, line 91.
    The first thing I do is setting a breakpoint as soon as your program enters the spellcheck function. You can also set breakpoints by line numbers but since you know that there's something wrong with this function the beginning of the function is a good starting point.

    Code:
    (gdb) r
    Starting program: test 
    
    Breakpoint 1, spellcheck (word=0x804a060 "hello", dictionary=0x804b170)
        at test.c:91
    91    {
    With "r" I start the program and it stops at the breakpoint (we're now at line 91). gdb also shows you the parameters for the function call.

    Code:
    (gdb) n
    92        int x, ch, flag, cmpr, ctr = 0;
    (gdb) n
    96        while((ch = fgetc(dictionary)) != EOF)
    (gdb) n
    98            if((ch != '\n'))
    (gdb) p ch
    $1 = 104
    With "n" you tell gdb to execute the next line. Thus you can step through the code line by line. (Notice: gdb will execute the current line and prints the next to be executed, i.e. if you see output like "98 if((ch != '\n'))" it means the program stopped at this line and hasn't executed it yet).
    So we are at line 98 now and with "p ch" I can print the current value of ch (104 is the ASCII code for "h"). So I expect that the program enters the body of the if-statement. Let's see if that's right:
    Code:
    (gdb) n
    100                word_in_dict[ctr] = ch;
    (gdb) n
    101                ctr++;
    (gdb) n
    102                continue;
    (gdb) n
    96        while((ch = fgetc(dictionary)) != EOF)
    (gdb) p word_in_dict
    $2 = "h\000\000\000\000\000\000\000^\210\004\b\b\260\004\b\364?-\000\000\000\000\000\000\000\000\000h\362\377\277\240F\022\000\005\000\000"
    Until now the program works as expected. The first character was read and added to word_in_dict (you can see that "h" is the first element of the array, the rest is just garbage which happened to be already there at this memory location).
    Code:
    (gdb) watch ch == '\n'
    Hardware watchpoint 2: ch == '\n'
    (gdb) continue 
    Continuing.
    Hardware watchpoint 2: ch == '\n'
    
    Old value = 0
    New value = 1
    0x08048922 in spellcheck (word=0x804a060 "hello", dictionary=0x804b170)
        at test.c:96
    96        while((ch = fgetc(dictionary)) != EOF)
    (gdb) p ch
    $3 = 10
    Now I could have continued to step through the code but this would be rather boring and time consuming. Instead I've chosen to set a watchpoint. This feature will set another kind of breakpoint which only stops the program if the given expression (here ch == '\n') is true. Thus I can jump directly to the next interesting part of the program: checking if we enter the else-branch if the read character is a newline. Just to show you that ch is really the newline-character (= ASCII code 10) I've printed it's value.
    Code:
    (gdb) n
    98            if((ch != '\n'))
    (gdb) n
    106                word_in_dict[ctr] = '\0'; // add terminator to make string
    (gdb) l
    101                ctr++;
    102                continue;
    103            }
    104            else
    105            {
    106                word_in_dict[ctr] = '\0'; // add terminator to make string
    107    
    108                if((cmpr = strcmp(word, word_in_dict)) == 0) // compare word to dictionary word
    109                {
    110                    return NULL; // match found, nothing further needs doing
    Everything is still fine until now. We've entered the else-branch and are now on line 106 ("l" will print some lines before and after the current line, so it gives you a nice overview when you aren't sure where exactly you are in your program). Let's continue stepping through the code:
    Code:
    (gdb) n
    108                if((cmpr = strcmp(word, word_in_dict)) == 0) // compare word to dictionary word
    (gdb) p word_in_dict
    $4 = "how\000\000\000\000\000^\210\004\b\b\260\004\b\364?-\000\000\000\000\000\000\000\000\000h\362\377\277\240F\022\000\005\000\000"
    (gdb) p word
    $5 = 0x804a060 "hello"
    The next line to execute is the comparison. I print both word_in_dict and word to check if the have the expected values.
    Code:
    (gdb) n
    112                ctr = 0; // reset array position to accept new word
    (gdb) n
    114            return word; // if no matches between word and any dictionary words, return word to main()
    The words didn't compare equal as expected and ctr is set to 0. But look carefully now at our current line. We are at line 114 which means the next command will be the return statement. That's not what we want, so we've found our bug.
    Just to prove that we will really return to main() after only comparing the first in the dictionary, I continued stepping through the code:
    Code:
    (gdb) n
    116    }
    (gdb) n
    
    Watchpoint 2 deleted because the program has left the block in
    which its expression is valid.
    0x08048699 in main () at test.c:33
    33            if(spellcheck(word, dictionary) == NULL)
    It's true, we're back in main because the return statement is on the wrong location.

    As I've said before, if you know some basic debugging commands (setting breakpoints, stepping through the code, printing variable values) you will be able to fix your bugs much faster than waiting for someone here on the forum.

    Bye, Andreas

  15. #30
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Perfect tip from oogabooga! Open the file every time spellcheck is invoked,in order to traverse through the whole dictionary for every word

    this sounds very slow for a BIG dictionary i would say.. cfanatac if you like i could tell you a tip about that (or maybe i will tell you when we have this finished )

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strange behaviour
    By cfanatic in forum C Programming
    Replies: 2
    Last Post: 07-16-2012, 06:41 AM
  2. strange behaviour
    By cfanatic in forum C Programming
    Replies: 9
    Last Post: 07-13-2012, 10:41 PM
  3. Strange behaviour of GCC
    By BlackOps in forum C Programming
    Replies: 14
    Last Post: 07-29-2009, 06:44 PM
  4. strange behaviour.......
    By surdy in forum C Programming
    Replies: 2
    Last Post: 05-01-2004, 11:50 AM
  5. Strange behaviour
    By PrivatePanic in forum Windows Programming
    Replies: 11
    Last Post: 07-23-2002, 12:54 AM