title: How pointers to function as struct member useful in C?
body: <p>I am not new to C programming. But I don't understand what is usefulness to keep pointer to function as a structure member in C. e.g.     </p>
  
  <pre><code>    // Fist Way: To keep pointer to function in struct
      struct newtype{
          int a;
          char c;
          int (*f)(struct newtype*);
      } var;
      int fun(struct newtype* v){
          return v-&gt;a;
      }
  
      // Second way: Simple
      struct newtype2{
          int a;
          char c;
      } var2;
      int fun2(struct newtype2* v){
          return v-&gt;a;
      }
  
      int main(){
  
          // Fist: Require two steps
          var.f=fun;
          var.f(&amp;var);
  
          //Second : simple to call
          fun2(&amp;var2);    
      }
  </code></pre>
  
  <p>Does programmers use it to give Object Oriented(OO) shape to there C code and provide abstract object? Or to make code look technical.   </p>
  
  <p>I think, in above code second way is more gentle and pretty simple too. In fist way, we still have to pass <code>&amp;var</code>, even <code>fun()</code> is member of struct.  </p>
  
  <p>If its good to keep function pointer within struct definition, kindly help to explain the the reason.</p>