From 2a2270835033358f8146e316ae710cdc10c6d898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barra=20=C3=93=20Cath=C3=A1in?= Date: Thu, 18 Apr 2024 14:38:38 +0100 Subject: [PATCH] Added the useless clock. --- the-worlds-least-useful-clock.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 the-worlds-least-useful-clock.c diff --git a/the-worlds-least-useful-clock.c b/the-worlds-least-useful-clock.c new file mode 100644 index 0000000..a3c3449 --- /dev/null +++ b/the-worlds-least-useful-clock.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include + +int main (int argc, char ** argv) +{ + time_t timestamp; + struct tm * timeinfo; + srand(time(NULL)); + + while (true) + { + time(×tamp); + timeinfo = localtime(×tamp); + if ((rand() % 10) == 0) + { + printf("The time is now for coffee. Coffee time it is.\n"); + } + else + { + printf("The time is now: %s", asctime(timeinfo)); + } + + fflush(stdout); + sleep(rand() % 12); + } + + return 0; +}