From 8aaaa41621f9ddc87e1f7b2e2c59ed095bba7304 Mon Sep 17 00:00:00 2001 From: Kyle K Date: Tue, 8 Aug 2017 15:01:16 -0500 Subject: GNU Build system helloworld example using autotools --- helloworld.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 helloworld.c (limited to 'helloworld.c') diff --git a/helloworld.c b/helloworld.c new file mode 100644 index 0000000..be8fd70 --- /dev/null +++ b/helloworld.c @@ -0,0 +1,36 @@ +/* helloworld.c: A program to show the time since the Epoch */ + +#include +#include "config.h" + +#ifdef HAVE_SYS_TIME_H +#include +#else +#include +#endif + +double get_sec_since_epoch() +{ + double sec; + + #ifdef HAVE_GETTIMEOFDAY + struct timeval tv; + + gettimeofday(&tv, NULL); + sec = tv.tv_sec; + sec += tv.tv_usec / 1000000.0; + #else + sec = time(NULL); + #endif + + return sec; +} + +int main(int argc, char* argv[]) +{ + printf("hello, world! epoch is: "); + printf("%f\n", get_sec_since_epoch()); + + return 0; +} + -- cgit v1.2.3