Created
November 12, 2019 22:42
-
-
Save davidwhitney/ad694616673e61eaaeb3e482768b5c97 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
typedef struct { | |
const char* key; | |
int value[100]; | |
} key_value_pair; | |
const auto empty = new key_value_pair(); | |
key_value_pair images[] { | |
{"snowman", {1, 2, 3, 4, 5} }, | |
{"pig", {5, 2, 4, 5, 6} } | |
}; | |
key_value_pair* value_for(const char* key) { | |
for (auto i = 0; i < sizeof images; i++){ | |
if (images[i].key != key) { continue; } | |
return &images[i]; | |
} | |
return empty; | |
} | |
void print_bytes() { | |
auto kvp = value_for("pig"); | |
for (auto i = 0; i < 100; i++) { | |
Serial.print(kvp->value[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Arduino