/* * sample-main.c: a C program that uses sample-header.h. * Free sample from 99helpers.com/file-types/h * * Build: list both .c files; the header is never compiled on its own. * cc -Wall -Wextra -std=c17 sample-main.c sample-header.c -o stats-c * ./stats-c */ #include #include "sample-header.h" #include "sample-header.h" /* twice on purpose: the include guard makes the second copy empty, so nothing is redefined */ int main(void) { static const double temperatures[] = {12.5, 14.0, 9.5, 17.25, 15.0, 11.75}; stats_t week; stats_init(&week); for (size_t i = 0; i < sizeof temperatures / sizeof temperatures[0]; i++) { stats_add(&week, temperatures[i]); } printf("%s (C)\n", stats_library_name); printf("%zu values, mean %.2f, min %.2f, max %.2f\n", stats_count(&week), stats_mean(&week), stats_min(&week), stats_max(&week)); return 0; }