Browse Source

added a function that calls commands by their id

remotes/origin/georg
KaffeeMaus 1 year ago
parent
commit
905f0d21bf
  1. 12
      src/main/c/Georg/tictactoe.c

12
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;

Loading…
Cancel
Save