title: Start reading from a specific line from a .txt file MFC C++
body: <p>I am trying to read from a specific line in a text file. The lines are not the same in the text file for example.</p>
  
  <pre><code>INFO 2013-12-18 00:00:06,331 Thread-3 2032 CommonMMC.request_hardware_state() - Common 4 State = PASS (warn=False,fail=False)
  INFO 2013-12-18 00:00:06,331 Thread-3 2032 request_cooling_system_status -&gt; WARN (took 4.11000013351s)
  INFO 2013-12-18 00:00:08,674 Thread-8 544 request_status_for_unit -&gt; ({'FanSh7_2': 'Pass', 'State': 'Active', 'PDU_Internal': 'Pass', 'FanSh5_2': 'Pass', 'AirTemp': 'Pass', 'FanSh5_1': 'Pass', 'SecondaryWaterTemp': 'Pass', 'FanSh2_1': 'Pass', 'LowWaterLevel': 'Pass', 'FanSh2_2': 'Pass', 'FanSh3_1': 'Pass', 'FanSh3_2': 'Pass', 'DifferentialPumpPressure': 'Pass', 'PostPumpPressure': 'Pass', 'FanSh1_2': 'Pass', 'FanSh6_1': 'Pass', 'FanSh1_1': 'Pass', 'FanSh7_1': 'Pass', 'WaterPump': 'Pass', 'FanSh4_2': 'Pass', 'FanSh4_1': 'Pass', 'FanSh6_2': 'Pass', 'HighWaterLevel': 'Pass', 'PrePumpPressure': 'Pass', 'UnitNumber': 2, 'WaterValve': 'Pass'}, {'AirTemp_upper': 208, 'Current': 180, 'PrimaryWaterTempHexOut': -9999, 'ValveDmd': 92, 'PDU_Internal': 0, 'Target': 180, 'FanSh5_2': 3863, 'AirTemp': 205, 'FanSh5_1': 4185, 'SecondaryWaterTempReturn': -9999, 'FanSh2_1': 3995, 'FanSh2_2': 4185, 'SecondaryWaterTempFlow': 180, 'FanSh3_1': 3906, 'FanSh3_2': 4185, 'WaterValvePosition': 92, 'DifferentialPumpPressure': 940, 'FirmwareVersion': '01.36', 'PostPumpPressure': 2347, 'kD': 0, 'FanSh6_1': 3906, 'kI': 9220, 'FanSh1_2': 4235, 'FanSh1_1': 3906, 'ValveIndex': 92, 'WaterTempSensorFlow': 'OmegaTH1044006', 'kP': 0, 'FanSh7_1': 4185, 'WaterPump': 'On', 'Error': 0, 'FanSh4_2': 4185, 'FanSh4_1': 3906, 'FanSh6_2': 4185, 'WaterValveEndStop': 'BetweenStops', 'FanSh7_2': 3906, 'SecondaryWaterTarg': 180, 'PrePumpPressure': 1407, 'UnitNumber': 2, 'PrimaryWaterTempHexIn': -9999}) (took 2.29699993134s)
  INFO 2013-12-18 00:00:09,456 Thread-7 120 do_dc_channel_diagnostic -&gt; {'Channel=28': 'SupplyOn', 'Channel=29': 'SupplyOn', 'Channel=22': 'SupplyOn', 'Channel=23': 'SupplyOn', 'Channel=20': 'SupplyOn', 'Channel=21': 'SupplyOn', 'Channel=26': 'SupplyOn', 'Channel=27': 'SupplyOn', 'Channel=24': 'SupplyOn', 'Channel=25': 'SupplyOn', 'Channel=9': 'SupplyOn', 'Channel=8': 'SupplyOff', 'Channel=3': 'SupplyOn', 'Channel=2': 'SupplyOn', 'Channel=1': 'SupplyOn', 'Channel=0': 'SupplyOn', 'Channel=7': 'SupplyOn', 'Channel=6': 'SupplyOff', 'Channel=5': 'SupplyOff', 'Channel=4': 'SupplyOff', 'Channel=33': 'SupplyOn', 'Channel=13': 'SupplyOn', 'Channel=12': 'SupplyOn', 'Channel=11': 'SupplyOff', 'Channel=10': 'SupplyOpenCircuit', 'Channel=17': 'SupplyOn', 'Channel=16': 'SupplyOn', 'Channel=15': 'SupplyOn', 'Channel=14': 'SupplyOn', 'Channel=31': 'SupplyOn', 'Channel=30': 'SupplyOn', 'Channel=19': 'SupplyOn', 'Channel=18': 'SupplyOn', 'Channel=32': 'SupplyOn'} (took 2.82800006866s)
  </code></pre>
  
  <p>Background of project :</p>
  
  <p>My parser utility should go to this text file which is being updated constantly every few seconds and parse the text from there as frequent as the user specified, for example, 5 mins, 10 mins, 15 mins and so on. </p>
  
  <p>The problem that I am facing now is the first run of the program as the user may <strong>start the program at 5.05pm and at an interval of 15 minutes</strong>. I have made the program intelligent enough to get the timer to start at the nearest hour which in this case will be <strong>5.15pm</strong>. </p>
  
  <p>/////First Run////</p>
  
  <p>My program should recursively check for the time in each text line till it finds that the time is either the same or later and starts running from there till the EOF for the first run. I have managed to make it search and get the right time through some CTime functions and CString.</p>
  
  <pre><code>SYSTEMTIME st;
  GetLocalTime(&amp;st);
  CString mill;
  mill.Format("%02d", st.wMinute);
  mill2.Format("%02d:%02d", st.wHour, st.wMinute);
  First_Minute = atoi(mill);
  </code></pre>
  
  <p>This is defined at the start. Reason is that i want to first check for the hour and minute to be the same from the text line(since its being updated every few seconds) and then only checking the first minute which i converted to int. </p>
  
  <p>The next few codes are my compare method that compares the first minute against the text line</p>
  
  <pre><code>INFO 2013-12-18 00:00:00,299 Thread-3 2032 CommonMMC.request_hardware_state() - Common 4 State = PASS (warn=False,fail=False)
  </code></pre>
  
  <p>compare code</p>
  
  <pre><code>while ((result = fscanf(readLOG_fp, "%[^\n]\n", ReadLogLine)) != EOF) // Loops through the file till it reaches the end of file
  {
      CString CurrLine = ReadLogLine;
      Cstring CurrLine_Check = CurrLine;       
  
      if (first_run)
      {
          int n = CurrLine_Check.Find(mill2);
  
          if (n == 16)
          {
              int a = CurrLine_Check.GetLength();
              CurrLine_Check.Delete(24, (a-24));
              CurrLine_Check.Delete(0, 22);
              int b = atoi(CurrLine_Check);
  
              if (First_Minute &gt;= b)
              {
                      Sort_Array();
              }
          }
      }
  if (first_run == false)
      {
          Sort_Array();
      }
  }
  fclose(readLOG_fp);
  first_run = false;
  </code></pre>
  
  <p>Basically what this does is its checks from the current line for the instance of mill2 which has been defined <strong>"%02d:%02d"</strong> and is compared to the text line. after that is found, another if loop is placed inside to check for the minute which i have converted aswell to an int.</p>
  
  <p>If the first minute(defined at start of program) is more than equals the minute that is checked from the text line, it would run the sort_array function. </p>
  
  <p>My question is I want the program to run till the EOF when it hits that if loop. Is there a way to start scanning from a specified line, for example line 10? as I am thinking to put a counter in that if loop. </p>
  
  <p>I thought of having another while loop inside to loop it till the EOF but that wouldn't work as it will still pass through the time check.</p>
  
  <p>Thanks! and I thank you in advance for the help :)</p>