I am writing a code that takes two user inputted times and switches them all to seconds(using the function) gives me the elapsed time and stores it in my header file, then writes to screen elapsed time. I am having trouble in my function with Time1. and Time.2 coming up errors using pointers, struct, and I am sure much other problems. I really need help I am stuck! All is appreciated.
say I enter 12:15:30 for start time and end time 13:30:30 it should output my elapsed time is 1:15:00. this is the only code I have so far:
Code:
#include <iostream>
#include <fstream>
using namespace std;
struct MyTime { int hours,minutes, seconds; };
int DeterminedElapsedTime(struct Mytime *Time1, struct Mytime *Time2);
int main()
{
struct MyTime Time1;
struct MyTime Time2;
cout << "Input first clocktime and seccond clocktime " << endl;
cin >> Time1.hours >> Time1.minutes >> Time1.seconds >> Time2.hours >> Time2.minutes >> Time2.seconds;
}
int DeterminedElapsedTime(Mytime * Time1, Mytime * Time2)
{
return 0;
}
//my function:
int DeterminedElapsedTimestruct ( struct Mytime *Time1, struct Mytime *Time2)
{
double elapsedtime;
Time1 = Time1.hours*(3600) + Time1.minutes*(60) + Time1.seconds;
Time2 = Time2.hours*(3600) + Time2.minutes*(60) + Time2.seconds;
elapsedtime = Time1 - Time2;
return elapsedtime;
//and my header file:
struct MyTime { int hours, minutes, seconds; };