title: Converting 24 hour time to an integer value in C++
body: <p>I'm working on a project in school and our assignment goes like this.</p>
  
  <p>There is a input text file given with the following information</p>
  
  <pre><code>08:30 Jane 10:15 
  
  08:35 Eric 11:20
  
  08:45 Austin  11:45
  
  09:20 Mclaren 12:50
  </code></pre>
  
  <p>This is the entry time, name, and leave time for four employees who work at some company.</p>
  
  <p>What I'm supposed to do is find the person who stayed inside the longest and display their name. </p>
  
  <p>(All 3 informations are type string.)</p>
  
  <p>For this I have to subtract the entry time from the leave time for a person, make that into an integer value, do this for all other persons, and then compare all of these integers and find out which is the biggest.</p>
  
  <p>The problem is that I have no idea how to convert (for example) 08:45 to an integer. I know C++ can lexicographically compare the two and would be able to tell that 10:15 is greater than 9:45 but unfortunately it cannot subtract them. Is there a method that would do that in C++?</p>
  
  <p>Or would I have to do some complicated shit and make some sort of delimiter (the ":") and then take the first part of the string like 08, and take that as the hour, multiply it by 60 (after 08 is converted to the int 8 somehow) to obtain minutes, then take the value after delimiter and add it to that (after the minutes were converted to int), to obtain the total minutes? Sounds very complicated to me, also my knowledge in C++ is limited but I would guess this way of doing things would need a huge switch table which would convert '08' to the integer 8 and so on and so forth all the way from 00 to 60 (60 cases).</p>
  
  <p>There must be a far easier way. Any help would be appreciated.</p>
  
  <p>EDIT: To clarify, I already know how to isolate the times out of the text file and put them into seperate strings. I need help with the conversion itself. How to convert the time in that string format to a useable integer value.</p>
  
  <p>EDIT2: Solved with substring and atoi. Thanks for help.</p>