Hello friends, I have a small problem with integers... I want to get the seconds of the time in format HHMMSS. My code is:
int get_seconds( int time ) {
cout << time << endl;
int sec = time % 100; time /= 100; cout << time << endl;
sec += (time % 100)*60; time /= 100; cout << time << endl;
return sec + (time*60)*60;
}
So... if the time=121314 the code works great, but if the time starts with zero then the time value is "converted into random number".
So, can you give me some code or example for solving this problem ?
Thanks.