Hi, hope someone can help with an issue I'm having.
Basically, I've got an input file containing, amongst other things, an int on each line representing a time stamp in the form of hhmmss. I needed to make a comparison from line to line to make sure that no more than 3 minutes goes between each set of measurements.
I tried setting it up so that the int was passed to a stringstream, converted to a string, then the substring for two digits at a time were passed to a different stringstream, then converted back to separate ints. The problem with this solution is that the time stamp is in military time, so it's potentially got multiple leading zeroes, which will be lost in the conversion process from int to string to int.
Is there a similar function to substr for an int? Or am I going about this the entirely wrong way? Any advice would be welcome.
Here's the currently non-operational snippet.
stringstream stampin, hoursin, minutesin, secondsin; string temp, tempa; int times; stampin << numbers; stampin >> temp; tempa = temp.substr(0,2); tempa = temp.substr(2,2); tempa = temp.substr(4,2); hoursin << tempa; minutesin << tempa; secondsin << tempa; hoursin >> times; minutesin >> times; secondsin >> times;
Edited 7 Years Ago by jmoran19: n/a