summaryrefslogtreecommitdiffstats
path: root/helloworld.c
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2017-08-08 15:01:16 -0500
committerKyle K <kylek389@gmail.com>2017-08-08 15:01:16 -0500
commit8aaaa41621f9ddc87e1f7b2e2c59ed095bba7304 (patch)
tree53b2cd73d2da693e12caa8f6bcb435364725e815 /helloworld.c
downloadhello_autotools-8aaaa41621f9ddc87e1f7b2e2c59ed095bba7304.tar.gz
hello_autotools-8aaaa41621f9ddc87e1f7b2e2c59ed095bba7304.tar.bz2
hello_autotools-8aaaa41621f9ddc87e1f7b2e2c59ed095bba7304.zip
GNU Build system helloworld example using autotoolsHEADmaster
Diffstat (limited to 'helloworld.c')
-rw-r--r--helloworld.c36
1 files changed, 36 insertions, 0 deletions
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 <stdio.h>
+#include "config.h"
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#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;
+}
+