title: jump table examples in C
body: <p>Please give me some examples of jump table usage. I have seen this example on wikipedia:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  typedef void (*Handler)(void);    /* A pointer to a handler function */
  
  
  
  /* The functions */
  void func3 (void) { printf( "3\n" ); }
  void func2 (void) { printf( "2\n" ); }
  void func1 (void) { printf( "1\n" ); }
  void func0 (void) { printf( "0\n" ); }
  
  
  
  Handler jump_table[4] = {func0, func1, func2, func3};
  
  
  
  int main (int argc, char **argv) {
      int value;
  
      /* Convert first argument to 0-3 integer (Hash) */
      value = atoi(argv[1]) % 4;
      if (value &lt; 0) {
          value *= -1;
      }
  
      /* Call appropriate function (func0 thru func3) */
      jump_table[value]();
  }
  </code></pre>
  
  <p>But I was wondering if there is an alternate way of calling the function instead of using index as shown, in the above case it is <code>jump_table[value]();</code></p>
  
  <p>What I want to achieve is, instead of using the index is there a way to use the name of the function itself.</p>
  
  <p>For example, say we have all the function pointers in a struct.</p>
  
  <pre><code>typedef struct _funcptrs
  {
    void func1();
    void func2();
  } funcptrs;
  </code></pre>
  
  <p>and now when I want to call the function can I do something like <code>funcptrs.func1()</code> ? </p>