Explore BrainMass

C program for Time conversion

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 July 19, 2018, 9:24 pm ad1c9bdddf

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.