Getting an error in the for loop that it is not in the scope not sure why? Tried to update using variables but still does not work. fdsdfdsfdsfsdfsddfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsfsdfssdfs fdfsdfsdfsdfsfsdfsdfsdfsdfsfsdfsfsdfsdfsdfsdfsdfsdfsdfsdfsdf dsfdsdfsdfsdfsdfsfsdfdsfsdfsdfsdfsdfsdfdsfsdfsdfsdfsdfsdfsdf sdfsdfdsfsdfsdfsdfdsfsdfsdfsdfsdfsdfsdfsdfdsfsdfsdfsdfsdfsff
#include <iostream>
#include <iomanip>
#include "C1A7E1_MyTime.h"
using namespace std;
MyTime *DetermineElapsedTime(const MyTime *tp1, const MyTime *tp2);
int main()
{
Here is the for loop that is the issue:
for (int loop_count = 0; loop_count < 3; loop_count++)
{
cout << "Enter time point one, space separated:\n";
cin >> tm1.hours >> tm1.minutes >> tm1.seconds;
cout << "Enter time point one, space separated:\n";
cin >> tm2.hours >> tm2.minutes >> tm2.seconds;
cout << "entering function!";
DetermineElapsedTime(const tm1, const tm2)
}
const MyTime tm1 = { 2, 0, 0};
const MyTime tm2 = { 0, 0, 0};
MyTime time_dif = *DetermineElapsedTime(&tm1, &tm2);
cout << "The time elapsed from ";
cout << setfill('0') << setw(2) << tm1.hours << ":";
cout << setfill('0') << setw(2) << tm1.minutes << ":";
cout << setfill('0') << setw(2) << tm1.seconds;
cout << " to ";
cout << setfill('0') << setw(2) << tm2.hours << ":";
cout << setfill('0') << setw(2) << tm2.minutes << ":";
cout << setfill('0') << setw(2) << tm2.seconds;
cout << " is ";
cout << time_dif.hours << ":" << time_dif.minutes << ":" <<
time_dif.seconds << "\n";
}
//C1A7E1_MyTime.h
#ifndef Class_Test_C1A7E1_MyTime_h
#define Class_Test_C1A7E1_MyTime_h
using namespace std;
struct MyTime { int hours, minutes, seconds; }; /* do not change this */
//#endif
//C1A7E1_DetermineElapsedTime.cpp
#include <iostream>
#include "C1A7E1_MyTime.h"
using namespace std;
MyTime *DetermineElapsedTime(const MyTime *tp1, const MyTime *tp2)
{
static MyTime return_time;
MyTime testy1, testy2;
testy1 = *tp1;
testy2 = *tp2;
long time_point_dif;
time_point_dif = (long(testy1.hours) * 3600 + long(testy1.minutes) *
60+long(testy1.seconds)) - \
(long(testy2.hours) * 3600 + long(testy2.minutes) * 60 +
long(testy2.seconds));
return_time.hours = int(time_point_dif / 3600);
time_point_dif -= return_time.hours * 3600;
return_time.minutes = int(time_point_dif / 60);
time_point_dif -= return_time.minutes * 60;
return_time.seconds = int(time_point_dif);
return(&return_time);
}
Aucun commentaire:
Enregistrer un commentaire