Q:

How to use switch and case for strings

Based on an answer of the following question:  How do I transform an IF statement with 2 variables onto a switch function using C?
I want to develop SWITCH and CASE macros to use it (like switch and case) for strings.
Some thing like that:
char buf[256];

SWITCH (buf) {
    CASE ("abcdef"):
        printf ("A1!\n");
        BREAK;
    CASE ("ghijkl"):
        printf ("B1!\n");
        BREAK;
    DEFAULT:
        printf ("D1!\n");
        BREAK;
}

what could be SWITCH and CASE and BREAK and DEFAULT here ?

A:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SWITCH(S) char *_S = S; if (0)
#define CASE(S) } else if (strcmp(_S, S) == 0) {switch(1) { case 1
#define BREAK }
#define DEFAULT } else {switch(1) { case 1

int main()
{
    char buf[256];

    printf("\nString - Enter your string: ");
    scanf ("%s", buf);

    SWITCH (buf) {
        CASE ("abcdef"):
            printf ("B1!\n");
            BREAK;
        CASE ("ghijkl"):
            printf ("C1!\n");
            BREAK;
        DEFAULT:
            printf ("D1!\n");
            BREAK;
    }
}

