Did a few exersises, most of the way through serial_logger.

This commit is contained in:
Gabe Venberg 2023-09-06 15:07:08 -05:00
parent 1f4cc71b96
commit 97fb8de5da
8 changed files with 331 additions and 20 deletions

View file

@ -0,0 +1,26 @@
#include <stdio.h>
#include <stdlib.h>
void function0(void) { printf("function 0\n"); }
void function1(void) { printf("function 1\n"); }
void function2(void) { printf("function 2\n"); }
typedef void (*VoidToVoid)(void);
int main(int argc, char *argv[]) {
VoidToVoid functions[3] = {function0, function1, function2};
if (argc != 2) {
printf("one argument only\n");
return EXIT_FAILURE;
}
unsigned char index = strtol(argv[1], NULL, 10);
if (index > 2) {
printf("argument must be between 0 and 2\n");
return EXIT_FAILURE;
}
functions[index]();
return EXIT_SUCCESS;
}