reading a file filling the words into array prblm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
int main()
{
    // Open the dictionary file and fill it here
    ifstream in_file;
    in_file.open("words.txt");
    
    vector<string> store;
    string word;
    //in_file >> word;
    while (in_file >> word)
    {
        store.push_back(word);
    }
    
    // Ask the user for the file to process
    cout << "Enter file name: ";
    string fname;
    cin >> fname;
    ifstream fin;
    fin.open(fname.c_str());
    if (fin.fail())
    {
        cerr << "File does not exist" << endl;
        return EXIT_FAILURE;
    }
    
    
    // Don't change this
    clock_t start = clock();

    // Open it and  check it here
    string word2;
    vector<string> str_wrd2;
    while (fin >> word2)
    {
        str_wrd2.push_back(word2);
        
    }
    
    fin >> word2;
    for (int i = 0; i < word2.length(); i++)
    {
        if (islower(word2[i]))
        {
            isupper(word2[i]);
        }
        if (!isalpha(word2[i]))
        {
            fin.unget();
        }
        
    }
     cout << "This word is not contained in the Dictionary: ";
    for (int i = 0; i < word2.length(); i++)
    {
        if (str_wrd2[i] != store[i])
        {
            
            cout << str_wrd2[i];
        }
    }
    
    
    // Don't change this
    clock_t end = clock();
    cout << "Time to check is " << (end - start) / CLOCKS_PER_SEC
        << " seconds. " << endl;
    
    return 0;
}


This is what i have so far and entering moby.txt this prints out
Enter file name: moby.txt
This word is not contained in the Dictionary: MOBYDICK;ORTHEWHALEbyHermanTime to check is 0 seconds. 


im pretty sure it has something to do with the while loops but dont know what it is. any help would be much appreciated thank you =]
oh and this is the pseudocode:
Open words.txt dictionary
Read the file, storing each word in a vector of string
Ask the user for the file to check and open the file
For each word in the file
Strip out any non-alpha characters and convert word to lowercase
If the word is not contained in the dictionary, print it
Print the number of "misspelled" words printed
Topic archived. No new replies allowed.