Created
March 11, 2020 15:33
-
-
Save jbrzozoski/0db403c5ad3920411e41f6ee3b0c0152 to your computer and use it in GitHub Desktop.
Example of indexed array declarations in c
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
#define ERROR_ALPHA 1 | |
#define ERROR_BETA 4 | |
#define ERROR_GAMMA 3 | |
#define ERROR_DELTA 2 | |
static const char *const strerr[] = { | |
[ERROR_ALPHA] = "Error Alpha", | |
[ERROR_BETA] = "Error Beta", | |
[ERROR_GAMMA] = "Error Gamma", | |
[ERROR_DELTA] = "Error Delta", | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that the order of the items in the array declaration don't have to match. I believe any gaps in the indexing should be initialized as if memclr().