Loving the support here; I am trying to compile the below - When it hits the
do { .. start_secs += incr_secs ..} --> It tells me it's a read-only variable - I'm rubbing my brain here - I'm like can I replace void here? I'm looking towards the Master JL - I've almost finished the program (evil laugh) - it will put the times in rows with other information!
I'm looking to put This Together.
Rules
1. Input Start Time
2. Input End Time
3. Input Increment Value
4. Add The Increment To Start Time, Show Each Time It Happens, Loop Until End Time Is Reached.
#include <iostream>
unsignedint to_secs_since_midnight( unsignedint hh, unsignedint mm, unsignedint ss )
{ return hh*3600 + mm*60 + ss ; }
void from_secs_since_midnight( unsignedint total_secs, unsignedint& hh, unsignedint& mm, unsignedint& ss )
{
hh = ( total_secs / 3600 ) % 24 ;
mm = ( total_secs / 60 ) % 60 ;
ss = total_secs % 60 ;
}
unsignedint get_secs_from_hh_mm_ss( constchar* prompt )
{
unsignedint hh, mm, ss ;
char sep ;
std::cout << prompt << " as HH:MM:SS:\n" ;
std::cin >> hh >> sep >> mm >> sep >> ss ;
return to_secs_since_midnight( hh, mm, ss ) ;
}
int main()
{
constunsignedint start_secs = get_secs_from_hh_mm_ss( "Give Me A Start Time At The Location" ) ;
constunsignedint ending_time = get_secs_from_hh_mm_ss( "Give Me An End Time At The Location" ) ;
constunsignedint incr_secs = get_secs_from_hh_mm_ss( "Give Me An Increment Of Events At The Location" ) ;
constunsignedint end_secs = start_secs + incr_secs;
unsignedint hh, mm, ss ;
from_secs_since_midnight( end_secs, hh, mm, ss ) ;
std::cout << "The End Time Is:\n" << hh << ':' << mm << ':' << ss << '\n' ;
do {std::cout << hh << ":" << mm << ":" << ss << "\n"; start_secs += incr_secs;}
//these variables are simple containers - how do I increment by the variable - as += will not work with compiler!?
while (start_secs <= ending_time);
return 0;
}
//Output Is Formatted Correctly - However - The += not working//
It WORKED !!!
The output is just start + interval - but DOES the calculations to reach the end time.
Gonna Work on the output here to make sure it's correct - It needs to display start time as it changes.