title: Using sqlite3_exec() to get single result in C
body: <p>I know there is a lot of posts and documentation out there on exactly how to use this function, but no matter what I do I can't quite grasp the concept of <code>callback</code> functions in regards to this API. So here's what I'm trying to do, I have a relation that looks like this:</p>
  <pre><code>+----+-------+
  | id | event |
  +----+-------+
  |  1 |    45 |
  |  2 |    22 |
  |  3 |    12 |
  +----+-------+
  </code></pre>
  <p>My goal is to use the following SQL statement <code>SELECT MAX(id) FROM events;</code> to get the value <code>3</code> back for later use in my C Code. I'm not exactly sure how to use <code>sqlite3_exec()</code> to get this single value. I'll leave my currently written code below to show where I'm currently at. Btw I'm not including my code to open the database because I know that works. Callback is empty because I'm not exactly sure how to use it. Thanks in advance for any help! (Please go easy on me, I'm trying to get community help to learn :))</p>
  <p><strong>Current sqlite3_exec() call</strong></p>
  <pre><code>int max_event_id;
  char *zErrMsg;
  
  //Error handling omitted for readability
  sqlite3_exec(database, &quot;SELECT MAX(id) FROM log_events;&quot;, max_id_callback, max_event_id, &amp;zErrMsg)
  </code></pre>
  <p><strong>max_id_callback() function (Currently Empty)</strong></p>
  <pre><code>static bool max_id_callback( void *max_id, int count, char **data, char **columns)
  {
  }
  </code></pre>