title: Wrapper function in C using structure of function pointers
body: <p>I have to write code in C where the user has to have flexibility in choosing any existing DB, write to files, or implement their own storage mechanism. I need wrapper functions that redirect to the right functions corresponding to the storage mechanism selected at runtime or compile time. Say my storage options are FLATFILE and SQLDB and my wrapper function is <em>insert(value)</em>. So, if I select FLATFILE as my storage, when I call the wrapper function <em>insert(value)</em>, it should in turn call the function that writes to a file. If I choose a SQLDB, <em>insert(value)</em> should call the function that insert the values in the data base.</p>
  
  <p>I know I can somehow use a structure of function pointers to do wrapper functions, but I have no idea how. </p>
  
  <p>Does anyone know of any docs, links, examples, etc I could refer to, to understand and implement something like this? Any pointers will be appreciated. Thanks!</p>
  
  <p>Thanks!</p>