From 9e9c1b21569faeabd33716e4153a881e2eed7134 Mon Sep 17 00:00:00 2001 From: Filip Wandzio Date: Sun, 1 Mar 2026 17:45:00 +0100 Subject: Separate quiz logic from main function fo dedicated module Signed-off-by: Filip Wandzio --- include/utils.h | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'include/utils.h') diff --git a/include/utils.h b/include/utils.h index 74c0ca1..08895c0 100644 --- a/include/utils.h +++ b/include/utils.h @@ -1,8 +1,30 @@ #pragma once + +#include #include +/** Print a horizontal separator line */ void print_line(void); -void wait_enter(const char *msg); -char ask_yes_no(const char *msg); -void now_str(char *buf, size_t size); -size_t rand_index(size_t max); + +/** Pause until the user presses ENTER */ +void wait_for_enter(const char* prompt); + +/** Ask a yes/no question and return boolean */ +bool ask_yes_no(const char* prompt); + +/** + * Get the current timestamp for recording when a question was answered + * + * @param answer_time_buffer Buffer to store the formatted timestamp + * @param buffer_capacity Size of the buffer in bytes + */ +void get_answer_timestamp(char* answer_time_buffer, size_t buffer_capacity); + +/** + * Get a random question index in the quiz (thread-safe) + * + * @param seed Pointer to an unsigned int seed (per-thread) + * @param total_questions Number of questions in the current quiz session + * @return Random index in the range [0, total_questions-1] + */ +size_t get_random_question_index(unsigned int* seed, size_t total_questions); -- cgit v1.2.3