title: C change behavior of function on behalf of input
body: <p>my program in C has some functionality (#obviously). The program gets input from the user, this user can then choose different implementations, e.g. myProgram -V1, or myProgram -V2 ...</p>
  <p>This specification of -V1, -V2, ... decides how the function performs a particular calculation.</p>
  <p>E.g..</p>
  <pre><code>for (int i = 0; i &lt; len; i++) {
    i += myFunctionWhichChangesBehaviorOnUserInput(arr[i]);
  } 
  </code></pre>
  <p>Now I don't want to create a separate function for each V and then change the respective myFunctionWhichChangesBehaviorOnUserInput() function there.</p>
  <p>I know you can do it this way in java.</p>
  <pre><code>interface Compute {
    double compute(double n);
  }
  
  ... some imple of Compute 
  
  class Task {
    Compute compute;
  
    void setCompute(Compute c) {this.compute = c}
  
    double doMyStuff(double[] arr) {
      double n = 0;
      for (int i = 0; i &lt; arr.length; i++) {
        n += compute.compute(arr[i]);
      }
      return n;
    }
  }
  
  </code></pre>
  <p>How can you implement this in C, must be possible somehow.</p>