title: C++ - Comparing only time
body: <p>Is there a way to only compare time in C++? </p>
  
  <p>For instance, given a array of predefined time (in string, e.g. "04:00", "07:00", "13:00") I want to be able to compare the current time with the range of time given in the array to see which fits. </p>
  
  <p>I have tried <code>strptime</code> but I keep getting the undefined error. I have included <code>time.h</code> and <code>stdio.h</code>.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;ctime&gt;
  #include &lt;time.h&gt;
  
  int main() {
  
      //GET CURRENT TIME
      time_t now = time(0);
      tm *ltm = localtime(&amp;now);
      cout &lt;&lt; "Time: "&lt;&lt; ltm-&gt;tm_hour &lt;&lt; ":";
      cout &lt;&lt; ltm-&gt;tm_min &lt;&lt; ":";
      cout &lt;&lt; ltm-&gt;tm_sec &lt;&lt; endl;
  
      //TRYING TO CONVERT THE TIME FROM STRING TO PROCEED FOR FURTHER COMPARISON
      struct tm tm;
      std::string s("04:00");
      if (strptime(s.c_str(), "%H:%M", &amp;tm)) { //error strptime is undefined
          int d = tm.tm_mday,
              m = tm.tm_mon + 1,
              y = tm.tm_year + 1900;
          std::cout &lt;&lt; y &lt;&lt; "-" &lt;&lt; m &lt;&lt; "-" &lt;&lt; d &lt;&lt; " "
                    &lt;&lt; tm.tm_hour &lt;&lt; ":" &lt;&lt; tm.tm_min;
      }
  
      //ATTEMPT TO DO TIME COMPARISON HERE
  }
  </code></pre>
  
  <p>Am I missing out on any library? </p>
  
  <p>Is there an easier/alternate way to do this? </p>
  
  <p>Please guide me. Thanks</p>