title: How do I select data from an sqlite3 database into variables using sqlite3_exec?
body: <p>There are a million examples on the interweb detailing the use of <code>sqlite3_exec</code> to select rows from a table and printing them using this callback function:</p>
  
  <pre><code>static int callback(void *NotUsed, int argc, char **argv, char **azColName){
    int i;
    for(i=0; i&lt;argc; i++){
      printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
    }
    printf("\n");
    return 0;
  }
  </code></pre>
  
  <p>This is the code that implements <code>callback</code>:</p>
  
  <pre><code>[...]
  rc = sqlite3_exec(db, sql, callback, &amp;nrecs, &amp;zErrMsg);
  [...]
  </code></pre>
  
  <p>Now, I would assume that using the fetched data for something other than just printing would be a rather standard scenario, but for the life of me I cannot find out how this is supposed to be accomplished.</p>
  
  <p>What I wish to do is fetch one row (<code>argc</code> will be 1) containing two columns and have these two values (<code>argv[0]</code> and <code>argv[1]</code>) accessible from where <code>sqlite3_exec</code> was executed.</p>
  
  <p>I suppose this has something to do with the <code>void *NotUsed</code>. (What in the world is this a pointer to and why do all examples insist on not using it?)</p>
  
  <p>If someone could help me with this i would be ever so grateful. If you could also explain to me why this seemingly trivial task has been made so complicated you will have my undying love. (The fetched data is handled in a static function called from another function. This effectively kills the purpose of using an object oriented language, right?)</p>