int main (void) {
    int pos;

    while (1) {

       word = GetNextWord();
       if ( 0 == word.length() )  {
           DumpDictionary(dictionary,count);
           break;
       }
       if ((pos = LocateWord(dictionary,word)) >=  0 ) 
           count[pos]++;
       else
           if (!InsertWord(dictionary,word)) cout << "dictionary full " << word << " cannot be added\n";
    }
    return 0;
}
Esempio n. 2
0
int main (void) {

    ENTRY *pos;

    while (1) {
       word = GetNextWord();
       if ( word.empty() )  {
           DumpDictionary(dictionary);
           break;
       }
       if ((pos = LocateWord(dictionary,word)) >  0 ) 
           pos->count++;
       else
           if (!InsertWord(dictionary,word)) cout << "dictionary full" << word <<  "cannot be added\n";
    }
    delete pos;
    return 0;
}