Question: please can any one edit this code for me it does not calculate the difference between the two time #include #define maxsize 10 void getData(int*
please can any one edit this code for me it does not calculate the difference between the two time
#include #define maxsize 10
void getData(int* phr1, int* pmin1, int* psec1, int* phr2, int* pmin2, int* psec2);
void differenceTimePeriod(long, long, int*, int*, int*);
void printResults(int hr1, int min1, int sec1, int hr2, int min2, int sec2, int hr, int min, int sec);
int main(void) { // Local Declarations int min, hr, sec, hr2, hr1, min2, min1, sec1, sec2, i; long end[maxsize]; long start[maxsize];
// Statements for (i = 0; i < 5; i++) { getData(&hr1, &min1, &sec1, &hr2, &min2, &sec2); differenceTimePeriod(start, end, &min, &hr, &sec); if (hr < 25) { printResults(hr1, min1, sec1, hr2, min2, sec2, hr, min, sec);
} } _getch(); return 0; } // main
void getData(int* phr1, int* pmin1, int* psec1, int* phr2, int* pmin2, int* psec2) { // statements printf("Enter Time 1: HH:MM:SS "); scanf_s("%d:%d:%d", phr1, pmin1, psec1); printf("Enter Time 2: HH:MM:SS "); scanf_s("%d:%d:%d", phr2, pmin2, psec2); return; }
void differenceTimePeriod(long start, long end, int* min, int* hour, int* sec) { // Local Declarations long localtime1, localtime2; int sec1, sec2, min1, min2, hour1, hour2;
// Statements localtime1 = start; localtime2 = end; sec1 = localtime1 % 100; sec2 = localtime2 % 100; localtime1 = localtime1 / 100; localtime2 = localtime2 / 100; min1 = localtime1 % 100; min2 = localtime2 % 100; localtime1 = localtime1 / 100; localtime2 = localtime2 / 100; hour1 = localtime1; hour2 = localtime2; if (sec2 < sec1) { min2--; sec2 += 60; } if (min2 < min1) { hour2--; min2 += 60; } *hour = hour2 - hour1; *min = min2 - min1; *sec = sec2 - sec1; if (*hour > 24) printf(" Error more than 24 hour delay ");
void printResults(int hr1, int min1, int sec1, int hr2, int min2, int sec2, int hr, int min, int sec) { printf("Time Stamp 1:"); printf("%02d:%02d:%02d ", hr1, min1, sec1); printf("Time Stamp 2:"); printf("%02d:%02d:%02d ", hr2, min2, sec2); printf("Elapsed Time: ", hr, min, sec); return; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
