Created
August 2, 2016 14:26
-
-
Save rkujawa/352fcc7d70197764af5c60bf16a3b677 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
struct code_data { | |
uint8_t len; | |
char *name; | |
}; | |
struct code_data commands[] = { | |
{0, "noop"}, /* 0 */ | |
{0, "foobar"}, | |
{2, "thing-taking-two-args"}, | |
{10, "omgthisishuge"} /* 3 */ | |
/* ... */ | |
}; | |
void print_command(uint8_t c) | |
{ | |
printf("command %d : %s taking %d args\n", c, commands[c].name, | |
commands[c].len ); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
print_command(0); | |
print_command(1); | |
print_command(2); | |
print_command(3); | |
} | |
/* | |
command 0 : noop taking 0 args | |
command 1 : foobar taking 0 args | |
command 2 : thing-taking-two-args taking 2 args | |
command 3 : omgthisishuge taking 10 args | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment