title: Algorithm for Writing a Command Interpreter
body: <p>I am writing a shell that needs a command interpreter. The current pattern I am using is as follows:</p>
  
  <pre><code>if(strcmp(command, "my_cmd_keyword1") == 0) {
    ...
  }
  else if(strcmp(command, "my_cmd_keyword2") == 0) {
    ..
  }
  ...
  </code></pre>
  
  <p>However, the number of predefined command keywords might be very huge. The if-else branching turns out to be inefficient since it has to compare with every keyword (in the worst case). Is there any more efficient way to handle this? I am using C/C++ languages for my applications.</p>