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[3];
int times[3];
stampin << numbers[2];
stampin >> temp;
tempa[0] = temp.substr(0,2);
tempa[1] = temp.substr(2,2);
tempa[2] = temp.substr(4,2);
hoursin << tempa[0];
minutesin << tempa[1];
secondsin << tempa[2];
hoursin >> times[0];
minutesin >> times[1];
secondsin >> times[2];