From 905f0d21bf285d2172e1f99728302356be414198 Mon Sep 17 00:00:00 2001 From: KaffeeMaus Date: Fri, 26 Jan 2024 11:33:19 +0100 Subject: [PATCH] added a function that calls commands by their id --- src/main/c/Georg/tictactoe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/c/Georg/tictactoe.c b/src/main/c/Georg/tictactoe.c index 6eaa000..7c09e45 100644 --- a/src/main/c/Georg/tictactoe.c +++ b/src/main/c/Georg/tictactoe.c @@ -51,6 +51,18 @@ struct command* createCommands(){ return ptrCommands; } +commandFunction getCommandById( struct command* commands, int id ){ + commandFunction result = NULL; + size_t arraySize = sizeof(*commands) / sizeof(commands[0]); + for (size_t i = 0; i < arraySize; i++) { + if( commands[i].id == id ){ + result = commands[i].fun; + break; + } + } + return result; +} + int startMenu(){ return 1;