C/C++ switch case with string
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4165131/c-c-switch-for-non-integers">C/C++: switch for non-integers</a>  </p>
</blockquote>



<p>Hi,
I need to use a string in switch case. My solution so far was to calculate the hash of the string with my hash function. Problem is I have to manually pre-calculate all my hash values for strings. Is there a better approach? </p>

<pre><code>h=_myhash (mystring);
switch (h)
{
case 66452:
   .......
case 1342537:
   ........
}
</code></pre>
