title: String Comparision
body: <p>How are the word files stored in a text file.</p>
  <p>I am trying to take a word as input from  and comparing that word with the words present in my local path.</p>
  <p>how to compare the input word to the words in the file.</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  string str;
  fstream file;
  string word, t, q, filename;
  
  void read()
  {
      cout &lt;&lt; &quot;Enter the word to search in the dictionary:&quot;;
      cin &gt;&gt; str;
      cout &lt;&lt; &quot;Your Entered word is :&quot; &lt;&lt; str;
      cout &lt;&lt; &quot;\nsearching in the librabry(Dictionary).&quot;;
      return;
  }
  
  void search()
  {
      //string str;
      filename = &quot;da1.txt&quot;;
  
      file.open(filename.c_str());
      if (str == word)
      {
          cout &lt;&lt; &quot;Found&quot; &lt;&lt; word &lt;&lt; endl;
      }
      else
      {
          cout &lt;&lt; &quot;\nEntered word does not exist in the library.&quot; &lt;&lt; endl;
      }
      return;
  }
  
  int main()
  {
      search();
  }
  </code></pre>
  <p>I am pretty sure that my word is not being compared to the words in the text.</p>