
November 9th, 2012, 11:29 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 23
Time spent in forums: 12 h 34 m 7 sec
Reputation 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();
|