Loop Stops After One Run - Any Ideas?

Loop stops after one run - any ideas?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <cmath>
#include <fstream>
#include <string>
#include <iomanip>

using namespace std;
int main()
{
int str_hh;
int str_mm;
int str_ss;
int inc_hh;
int inc_mm;
int inc_ss;
int end_hh;
int end_mm;
int end_ss;
int hh;
int mm;
int ss;

unsigned int hola0;
unsigned int hola1;
unsigned int hola2;
unsigned int facetime;


cout << "Give Me A Start Time:\n";
char sep;
cin  >> str_hh >> sep >> str_mm >> sep >> str_ss;
hola0 = str_hh*3600 + str_mm*60 + str_ss;

cout << "Give Me An Increment Of Time:\n";
cin  >> inc_hh >> sep >> inc_mm >> sep >> inc_ss;
hola1 = inc_hh*3600 + inc_mm*60 + inc_ss;

cout << "Give Me An End Time:\n";
cin  >> end_hh >> sep >> end_mm >> sep >> end_ss;
hola2 = inc_hh*3600 + inc_mm*60 + inc_ss;

do 
{
    facetime = (hola0 += hola1); 
    hh = ( facetime / 3600 ) % 24 ; // %24 to handle roll over to the next day
    mm = ( facetime / 60 ) % 60 ;
    ss = facetime % 60 ;
    cout << hh << ":" << mm << ":" << ss;
}
while (hola2 >= hola0);
return 0;
}
//so ... it stops after one iteration - so mess with it until the loop contnues 
1
2
// hola2 = inc_hh*3600 + inc_mm*60 + inc_ss;
hola2 = end_hh*3600 + end_mm*60 + end_ss;


Your code is still not correct if the end time is after midnight (to start with, hola2 is less than hola0).
eg. start: 17:30:45 increment: 01:15:30 end: 04:30:50
Topic archived. No new replies allowed.