title: Search words in two text files c++
body: <p>I am new here. Anyway. I am trying to search a word in a text file(which has 10 sentences) from a text file that consists of few keywords. Basically i am trying to find if one of the keywords in file2 consist in file1. I have tried but it seems like it compares by line instead of word. if anyone could help me with this? thanks.</p>
  
  <pre><code>int main()
  {
    bool Found;
    int i = 0;
    int j = 0;
  
    string str;
    ifstream file;
    file.open("words.txt", ios::in | ios::binary);
  
    string str2;
    ifstream file2;
    file2.open("M4.txt", ios::in | ios::binary);
  
    while (!file.eof() &amp;&amp; !Found) {
      getline(file, str, ' ');
    }
  
    while (!file2.eof() &amp;&amp; !Found) {
      getline(file2, str2, ' ');
    }
  
    //  if (str == str2)
    if (file.get() == file2.get()) {
      cout &lt;&lt; "This order is valid. M3" &lt;&lt; endl;
  
    } else {
      cout &lt;&lt; "This order is invalid. M3" &lt;&lt; endl;
    }
  
    system("pause");
    return 0;
  }
  </code></pre>
  
  <p>I hope anyone can help with this. Have stuck at here for weeks :(</p>