title: Finding words in text file to extract data using C++
body: <p>I am trying to find the total amount of time spent doing a certain activity with C++ and Mac Automator (you do not need to know 
  Automator to help me). I am using Mac Automator to output a text file using "Event Summary" and "New Text File" actions. It outputs a text file like this:
  <a href="https://drive.google.com/file/d/0B0I6p3B-4pUnazJJVVY1RUxjVW8/view?usp=sharing" rel="nofollow">Viewable text file</a></p>
  
  <p>I am currently struggling over something very trivial; I cannot accurately find the words "Time" and "Date" in the text file. If I cannot find the words "Time" and "Date" I cannot begin processing the total amount of time spent doing that activity or whether that activity went over midnight (I sometimes work into the ams). So far I think I have spent four hours with mixed results. Any feedback would be appreciated.</p>
  
  <p>The code below is the code I am using at the moment. I can find the word "Time" and "Date" at the very start of the file, or if a ':' is in front of the word "Time" or "Date", but when it is on a different line the programs fails:</p>
  
  <pre><code>cout &lt;&lt; "Reading from the file...." &lt;&lt; endl;
  infile.open("calendar workflow text.txt");
  while(infile.getline(buff, BUFFSIZE, ':')){ //reads everything
      cout &lt;&lt; buff &lt;&lt; endl; // prints everything
      if(strcmp("Time",buff)==0){
          cout&lt;&lt;"Time found in text\n"&lt;&lt;endl;
      }
      else if (strcmp("Date",buff)==0){
          cout&lt;&lt;"Date found in text\n"&lt;&lt;endl;
      }
  }
  infile.close();
  cout&lt;&lt;"Total Time in all events: "&lt;&lt;sumtime&lt;&lt;" hrs"&lt;&lt;endl;
  return (0);
  </code></pre>
  
  <p>If you want the automator workflow I can give it to you.</p>