Fstream reversing

I am working on a homework assignment and I need to find the longest word from a list of almost 50,000 and the reverse that word.I think the word, once reversed, should be a real word. Ex (nuts = stun, wolf = flow). The code I have right now finds the longest word, then reverses the whole list and prints out the first word it comes to in the newly reversed list.

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
#include <iostream>
#include <fstream>
#include <cstdlib>


std::string word; 
std::string longest_word; 
using namespace std;

bool is_single_vowel(string word){
     //all words contain at least 1 vowel; find it:
           size_t found = word.find_first_of("aeiouAEIOU");
           //Handle Speacial Case: If no vowel was detected, 
           // word must be using single 'y' as a vowel:
           
           if(found == string::npos)
           return true;
           
       //Attempt to find any occurance of a second vowel
       found = word.find_first_of("aeiouAEIOU", found +1);
       
       //If no second vowel was detected, return TRUE
       if(found == string::npos)
       return true;
       //Else word contains two or more vowels
       else
       return false;
}



int main()
{
 ifstream inStream;
 string  word;
 string revWord;
 string::iterator it;
 string longest_word;
 int size;

inStream.open("words.txt", ifstream ::in);


while(inStream) {
       
       inStream >> word;
       

      //cout << word[ 0 ] ++;
      //system("pause");

    if (word.size () > longest_word.size () && is_single_vowel(word))
    longest_word = word;
   
} 

cout << "The longest word with one vowel is: " << /*revWord*/longest_word << endl;
 reverse(word.begin(), word.end());
  for(it=word.begin(); it!=word.end(); ++it)
  revWord+=*it;  

  longest_word = revWord;
 
 cout << revWord;
 
 inStream.close( );   
 
    system("PAUSE");
    return EXIT_SUCCESS;
}


I am not sure what I did wrong. Could someone please help me to see the mistake that I made?
Topic archived. No new replies allowed.