title: C++ populate vector from sqlite3 callback function?
body: <p>I have a sqlite3 table "addresses" like this:</p>
  
  <pre><code>+----+------+--------+
  | ID | name | number |
  +----+------+--------+
  | 1  | John | 413434 |
  +----+------+--------+
  </code></pre>
  
  <p>And i want to populate global vector, which i would be able to use somewhere else and join it with some other data.
  So far, i have this:</p>
  
  <pre><code>...
  #include &lt;sqlite3.h&gt;
  
  using namespace std;
  
  static int callbackDB(void *NotUsed, int argc, char **argv, char **szColName)
  {
      for(int i = 0; i &lt; argc; i++)
          cout &lt;&lt; szColName[i] &lt;&lt; " = " &lt;&lt; argv[i] &lt;&lt; endl;
  
      return 0;
  }
  
  int main(int argc, char* argv[]) {
      vector&lt;vector&lt;string&gt; &gt; table;
      for( int i = 0; i &lt; 2; i++ )
          table.push_back(std::vector&lt; std::string &gt;());
  
  
      sqlite3 *db;
      char *szErrMsg = 0;
  
      // open database
      int rc = sqlite3_open("database.db", &amp;db);
  
      const char *query;
      query = "SELECT * FROM addresses";
  
      rc = sqlite3_exec(db, query, callbackDB, 0, &amp;szErrMsg);
  
      return 0;
  }
  </code></pre>
  
  <p>How could i get results in vector or in some other way so that i'll be able to use it easier?</p>