Thread: Determine Elapsed time from two separate inputted times using function and header

  1. #1
    Registered User
    Join Date
    Feb 2016
    Posts
    1

    Determine Elapsed time from two separate inputted times using function and header

    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; };

  2. #2
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    You access members of pointers by using "->" instead of "."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. elapsed time
    By Solarwin in forum C++ Programming
    Replies: 14
    Last Post: 03-15-2013, 01:09 PM
  2. Replies: 2
    Last Post: 03-06-2012, 10:58 AM
  3. Replies: 4
    Last Post: 10-09-2011, 02:11 AM
  4. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 06:00 PM

Tags for this Thread