From 49fe65547475de870c5e6bfdf56c234a02b4d774 Mon Sep 17 00:00:00 2001 From: xesc Date: Sat, 12 Oct 2024 21:08:47 +0200 Subject: [PATCH] wte.c: add prototype for random selection --- src/wte.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/wte.c b/src/wte.c index 3c784ce..50e6fa5 100644 --- a/src/wte.c +++ b/src/wte.c @@ -2,10 +2,22 @@ #include #include "wte.h" +static size_t get_entry_count() +{ + size_t count = 0; + count++; + return count; +} -static int get_proposition() +static int make_suggestion() { int ret = 0; + srandom(time(NULL)); // seed random with current time + size_t count = get_entry_count(); + if (count) { + size_t choice = random() % count; + printf("choice: %lu", choice); + } return ret; } @@ -28,10 +40,10 @@ int main(const int argc, const char **argv) } goto exit_main; } - if (!get_proposition()) { - error("%s", "error"); - } + if (make_suggestion()) { + ret = 0; + } exit_main: return ret;