concept time in category c

appears as: times, times, time, time
Modern C

This is an excerpt from Manning's book Modern C.

The for statement tells the compiler that the program should execute the printf line a number of times. This is the simplest form of domain iterationC that C has to offer. It has four different parts.

The first class of times can be classified as calendar times, times with a granularity and range that would typically appear in a human calendar for appointments, birthdays, and so on. Here are some of the functional interfaces that deal with times and that are all provided by the time.h header:

time_t time(time_t *t);
double difftime(time_t time1, time_t time0);
time_t mktime(struct tm tm[1]);
size_t strftime(char s[static 1], size_t max,
                char const format[static 1],
                struct tm const tm[static 1]);
int timespec_get(struct timespec ts[static 1], int base);


!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":6}],[{\"line\":1,\"ch\":16},{\"line\":1,\"ch\":22}],[{\"line\":2,\"ch\":0},{\"line\":2,\"ch\":6}],[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":4}],[{\"line\":1,\"ch\":11},{\"line\":1,\"ch\":15}],[{\"line\":2,\"ch\":0},{\"line\":2,\"ch\":4}],[{\"line\":3,\"ch\":11},{\"line\":3,\"ch\":15}],[{\"line\":6,\"ch\":4},{\"line\":6,\"ch\":8}],[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":6}],[{\"line\":1,\"ch\":16},{\"line\":1,\"ch\":22}],[{\"line\":2,\"ch\":0},{\"line\":2,\"ch\":6}],[{\"line\":1,\"ch\":0},{\"line\":1,\"ch\":6}],[{\"line\":1,\"ch\":7},{\"line\":1,\"ch\":15}],[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":6}],[{\"line\":1,\"ch\":16},{\"line\":1,\"ch\":22}],[{\"line\":2,\"ch\":0},{\"line\":2,\"ch\":6}],[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":6}],[{\"line\":1,\"ch\":16},{\"line\":1,\"ch\":22}],[{\"line\":2,\"ch\":0},{\"line\":2,\"ch\":6}],[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":6}],[{\"line\":1,\"ch\":16},{\"line\":1,\"ch\":22}],[{\"line\":2,\"ch\":0},{\"line\":2,\"ch\":6}],[{\"line\":2,\"ch\":7},{\"line\":2,\"ch\":13}],[{\"line\":2,\"ch\":14},{\"line\":2,\"ch\":20}],[{\"line\":5,\"ch\":16},{\"line\":5,\"ch\":22}],[{\"line\":6,\"ch\":17},{\"line\":6,\"ch\":23}],[{\"line\":2,\"ch\":21},{\"line\":2,\"ch\":26}],[{\"line\":3,\"ch\":0},{\"line\":3,\"ch\":6}],[{\"line\":3,\"ch\":7},{\"line\":3,\"ch\":15}],[{\"line\":3,\"ch\":16},{\"line\":3,\"ch\":20}],[{\"line\":4,\"ch\":16},{\"line\":4,\"ch\":20}],[{\"line\":3,\"ch\":23},{\"line\":3,\"ch\":29}],[{\"line\":4,\"ch\":34},{\"line\":4,\"ch\":40}],[{\"line\":5,\"ch\":35},{\"line\":5,\"ch\":41}],[{\"line\":6,\"ch\":36},{\"line\":6,\"ch\":42}],[{\"line\":3,\"ch\":0},{\"line\":3,\"ch\":6}],[{\"line\":4,\"ch\":16},{\"line\":4,\"ch\":26}],[{\"line\":3,\"ch\":23},{\"line\":3,\"ch\":29}],[{\"line\":4,\"ch\":34},{\"line\":4,\"ch\":40}],[{\"line\":5,\"ch\":35},{\"line\":5,\"ch\":41}],[{\"line\":6,\"ch\":36},{\"line\":6,\"ch\":42}],[{\"line\":2,\"ch\":14},{\"line\":2,\"ch\":20}],[{\"line\":5,\"ch\":16},{\"line\":5,\"ch\":22}],[{\"line\":6,\"ch\":17},{\"line\":6,\"ch\":23}],[{\"line\":2,\"ch\":21},{\"line\":2,\"ch\":23}],[{\"line\":5,\"ch\":23},{\"line\":5,\"ch\":25}],[{\"line\":4,\"ch\":21},{\"line\":4,\"ch\":26}],[{\"line\":5,\"ch\":26},{\"line\":5,\"ch\":31}],[{\"line\":2,\"ch\":21},{\"line\":2,\"ch\":23}],[{\"line\":5,\"ch\":23},{\"line\":5,\"ch\":25}],[{\"line\":3,\"ch\":23},{\"line\":3,\"ch\":29}],[{\"line\":4,\"ch\":34},{\"line\":4,\"ch\":40}],[{\"line\":5,\"ch\":35},{\"line\":5,\"ch\":41}],[{\"line\":6,\"ch\":36},{\"line\":6,\"ch\":42}],[{\"line\":6,\"ch\":0},{\"line\":6,\"ch\":3}],[{\"line\":6,\"ch\":4},{\"line\":6,\"ch\":16}],[{\"line\":2,\"ch\":14},{\"line\":2,\"ch\":20}],[{\"line\":5,\"ch\":16},{\"line\":5,\"ch\":22}],[{\"line\":6,\"ch\":17},{\"line\":6,\"ch\":23}],[{\"line\":6,\"ch\":4},{\"line\":6,\"ch\":12}],[{\"line\":3,\"ch\":23},{\"line\":3,\"ch\":29}],[{\"line\":4,\"ch\":34},{\"line\":4,\"ch\":40}],[{\"line\":5,\"ch\":35},{\"line\":5,\"ch\":41}],[{\"line\":6,\"ch\":36},{\"line\":6,\"ch\":42}],[{\"line\":6,\"ch\":0},{\"line\":6,\"ch\":3}]]"}
!@%STYLE%@!

The first simply provides us with a timestamp of type time_t of the current time. The simplest form uses the return value of time(0). As we have seen, two such times taken from different moments during program execution can then be used to express a time difference by means of difftime.

  • Time handling in time.h has calendar time that is structured for human interpretation, and physical time that is structured in seconds and nanoseconds.