#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    23
    Rep Power
    0

    Help Please: Elapsed Time Function


    /* 3. Write a function elapsed_time that takes as its arguments two time structures and returns a time structure that represents the elapsed time (in hours, minutes, and seconds) between the two times. So the call elapsed_time (time1, time2) where time1 represents 3:45:15 and time2 represents 9:44:03, should return a time structure that represents 5 hours, 58 minutes, and 48 seconds. Be careful with times that cross midnight. */

    This is what I have so far, Im confused on where to put the function, how to return the times, and in general how I should proceed on this. Any help is appreciated.

    Code:
    #include <stdio.h> 
    #include <stdbool.h> 
    #inlcude <conio.h> 
    struct time // define structure 
    { int hour; int minute; int second; } 
    
    void elapsed_time(struct time1, struct time2, struct elapsed); // arguments are 2 time structures 
    int main(void) 
    { struct time time1, time2; printf ("Enter starting time (HH MM SS): "); 
    scanf ("%i%i%i". &time.hour, &time.minute, &time.second); getchar();
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,897
    Rep Power
    481
    I think the question is about this.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    23
    Rep Power
    0
    Originally Posted by b49P23TIvg
    I think the question is about this.
    Thanks for the reply, we weren't allowed to use the time header file. I eventually got something to work. Thanks.

IMN logo majestic logo threadwatch logo seochat tools logo