title: How to switch and case for string?
body: <p>I have the following code</p>
  
  <pre><code>#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;
      }
  }
  </code></pre>
  
  <p>If I generate the pre-processor code with <code>gcc -E</code>, I will get the following code</p>
  
  <pre><code>int main()
  {
      char buf[256];
  
      printf("\nString - Enter your string: ");
      scanf ("%s", buf);
  
      char *_S = buf;
      if (0) {
      } else if (strcmp(_S, "abcdef") == 0) {switch(1) { case 1:
          printf ("B1!\n");
          };
      } else if (strcmp(_S, "ghijkl") == 0) {switch(1) { case 1:
          printf ("C1!\n");
          };
      } else {switch(1) { case 1:
          printf ("D1!\n");
          };
      }
  }
  </code></pre>
  
  <p>But for some gcc defining <code>char *_S = buf;</code> in the middle of the code is not wolcome and could provide compilation error</p>
  
  <p>How to fix that in my macro?</p>
  
  <p>Please do not suggest to define <code>char *_S</code> as global (out of the <code>main</code>)</p>