Explore BrainMass

C program for Time conversion

This content was STOLEN from BrainMass.com - View the original, and get the solution, here!

Construct a library Time that contains the time-conversion functions (given a number of seconds, returns the equivalent number of minutes; given the number of minutes, returns the equivalent number of hours; given the number of hours, returns the equivalent number of days; given the number of seconds, returns the equivalent number of days). Write a driver program to test your library.

© BrainMass Inc. brainmass.com September 24, 2018, 8:18 am ad1c9bdddf - https://brainmass.com/computer-science/c/c-program-for-time-conversion-31576

Solution Preview

First compile the library file
gcc -c myTime.c
this will create myTime.o

then simply do
gcc -o test testTime.c myTime.o
remember that the header file myTime.h containing the signatures of the functions should be included in your test driver file

Here is the code file
/* To compile the functions into a library ...

Solution Summary

Three source code files will show you how to write appropriate functions to convert different time scales/metrics. This can be useful in
a) code to write software clock or watch
b) understanding of how to use multiple files for a single project
c) understanding of the use of header files

This will show how to compile multiple files into one executable file.