fork download
  1. #include <stdio.h>
  2. #define STATUS_OK 0x05
  3. #define STATUS_BAD 0x09
  4. #define LOOKUP_CASE(x) case x: return #x
  5.  
  6. const char *lookup_name(int val) {
  7. switch(val) {
  8. LOOKUP_CASE(STATUS_OK);
  9. LOOKUP_CASE(STATUS_BAD);
  10. default: return "<UNDEFINED>";
  11. }
  12. return NULL;
  13. }
  14.  
  15. int main(void) {
  16. printf("%s\n", lookup_name(STATUS_OK));
  17. printf("%s\n", lookup_name(STATUS_BAD));
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 1676KB
stdin
Standard input is empty
stdout
STATUS_OK
STATUS_BAD