title: C/C++ switch case on char arrays
body: <p>I have several data structures, each having a field of 4 bytes.</p>
  
  <p>Since 4 bytes equal 1 <code>int</code> on my platform, I want to use them in <code>case</code> labels:</p>
  
  <pre><code>switch (* ((int*) &amp;structure-&gt;id)) {
     case (* ((int*) "sqrt")): printf("its a sqrt!"); break;
     case (* ((int*) "log2")): printf("its a log2!"); break;
     case (((int) 'A')&lt;&lt;8 + (int) 'B'): printf("works somehow, but unreadable"); break;
     default: printf("unknown id");
  }
  </code></pre>
  
  <p>This results in a compile error, telling me the case expression does not reduce to an <code>int</code>.</p>
  
  <p>How can i use char arrays of limited size, and cast them into numerical types to use in <code>switch</code>/<code>case</code>?</p>