How to keep a word dictionary in one variable

Discussion in 'C' started by Clawsy, Sep 8, 2010.

  1. Clawsy

    Clawsy New Member

    Joined:
    Sep 8, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I have too make an application in C that uses a dictionary. I have 54000 words in a file, on per line and I need a way to handle it.
    - I first wanted to keep it in an array but as it's bigger that INT (32767) I cannot do that.
    - The second option is to keep all in a very long string but it seems it give me some errors and throws me out of program. I tried to use a pointer for char like this:
    Code:
     FILE *f=fopen("d.txt","r");
       char *line;
       while(fgets(line,sizeof(line),f)){
         strcat(str,line);//concatenate all strings to this one - does not work, the pointer does not contain that words...
         //  printf("%s\n",line);
       }
       fclose(f);
    
    Is there a way too keep this dictionary in a variable in C? I don't want too search in the file every time cause it's time consuming and not reliable.

    Thanks!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice