You could maybe deal with it by "borrowing" from the next highest "denomination". Something like:
Code:
if (finish_sec < start_sec) {
finish_sec += 60; // borrow 60 seconds
finish_min--; // from the minutes
}
if (finish_min < start_min) {
finish_min += 60; // borrow 60 minutes
finish_hour--; // from the hours
}
Alternatively (and perhaps better), you could convert the times to seconds, subtract those, then convert back to hours, minutes and seconds.
Code:
start_sec += start_hour * 3600 + start_min * 60;
finish_sec += finish_hour * 3600 + finish_min * 60;
if (finish_sec < start_sec) {
printf("The finish time is less than the start time!\n");
}
else {
elapsed_sec = finish_sec - start_sec;
elapsed_hour = elapsed_sec / 3600; // integer division "rounds" down
elapsed_sec %= 3600; // modulus operator yields remainder
elapsed_min = elapsed_sec / 60;
elapsed_sec %= 60;
printf("%02d:%02d:%02d\n", elapsed_hour, elapsed_min, elapsed_sec);
}