title: how do I use ' string::find ' to find a word in file using C++
body: <p>I'm creating a program that will open a file and search for a desired word within the text.
  I created the following word bank...</p>
  
  <pre><code>Lawyer    
  Smith Janes
  Doctor    
  Michael Zane
  Teacher   
  Maria Omaha
  
  
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;   
  using namespace std;   
  
  int main ()    
  {    
      // Declarations    
      string reply;    
      string inputFileName;    
      ifstream inputFile;    
      char character;
  
      cout &lt;&lt; "Input file name: ";    
      getline(cin, inputFileName);
  
      // Open the input file.    
      inputFile.open(inputFileName.c_str());      
  
     // Check the file opened successfully.    
      if ( ! inputFile.is_open())
      {   
                    cout &lt;&lt; "Unable to open input file." &lt;&lt; endl;    
                    cout &lt;&lt; "Press enter to continue...";    
                    getline(cin, reply);           
                    return 1;
      }
  </code></pre>
  
  <p>Now that I save the whole file into a string how could I search inside that string
  for a specific word I'm looking for... </p>
  
  <p>I'm learning C++ from this Website <a href="http://www.cprogramming.com/tutorial/lesson10.html" rel="nofollow">http://www.cprogramming.com/tutorial/lesson10.html</a></p>
  
  <p>I think you use  <code>string::find</code>  but I couldn't find much reference on how to search beside this wesite..</p>
  
  <p><a href="http://www.cplusplus.com/reference/string/string/find/" rel="nofollow">http://www.cplusplus.com/reference/string/string/find/</a></p>
  
  <p>This section will display the whole file.</p>
  
  <pre><code>    string original;
      getline(inputFile, original, '\0');
      cout &lt;&lt; original &lt;&lt; endl;    
      cout &lt;&lt; "\nEnd of file reached\n" &lt;&lt; endl;
  
      // Close the input file stream   
      inputFile.close();    
      cout &lt;&lt; "Press enter to continue...";    
      return 0;      
  }
  </code></pre>
  
  <p>This is how I think the program should act...</p>
  
  <pre><code>Please enter a word: Smith Janes
  Smith Janes Lawyer
  
   another example.... 
  
  Please enter a word: Doctor 
  Michael Zane Doctor
  </code></pre>