title: function call from struct array
body: <p>I have a struct array that has the format:</p>
  
  <pre><code>struct command functions[] = {
      {"1", function1},
      {"2", function2},
      etc....
  }
  </code></pre>
  
  <p>In a function run(char* function), I check if the parameter is equivalent to one of the strings stored in the struct array. If it is, I want to call the corresponding function. For example, if "1" is passed in, I call function1().</p>
  
  <p>How would this be accomplished? </p>
  
  <p>So far, I have </p>
  
  <pre><code>run(char* function) {
      for (int i = 0; i &lt; num_functions; i++) {
          if(*function == functions[i]) {
              return (*function)();
          }
      }
  }
  </code></pre>
  
  <p>With the following errors:</p>
  
  <pre><code>error: invalid operands to binary == (have int and struct command)
  error: called object *function is not a function
  </code></pre>