title: Retrieve and store data from sqlite to array c/c++
body: <p>I have a column of integers(containing port numbers) in my sqlite data base. Now I want to retrieve list of ports from sqlite in an array form in a function and send data to those port numbers. I tried to make a struct having pointer to Vector but it didn't work out. Making char pointers caused Segmentation error. Here is my code:</p>
  
  <pre><code>struct ConnIDs{
      vector&lt;int*&gt; *ids;
  };
  static int callback(void *NotUsed, int argc, char **argv, char **szColName)
  {
      ConnIDs *first=(ConnIDs *)NotUsed;
  
      for(int i = 0; i &lt; argc; i++)
      {
          if (strcmp(szColName[i], "ConnID") == 0)
          {
              first-&gt;ids-&gt;push_back(argv[i]);
          }
          std::cout &lt;&lt; szColName[i] &lt;&lt; " = " &lt;&lt; argv[i] &lt;&lt; std::endl;
      }
      std::cout &lt;&lt; "\n";
      return 0;
  }
  
  int main(){
      int result;
      sqlite3 *db;
      ConnIDs first;
  
      int count = 0; 
      char *szErrMsg = 0;
      int rc = sqlite3_open("Sqlite_Test.db", &amp;db);
      if(rc)
      {
          std::cout &lt;&lt; "Can't open database\n";
      } else
      {
          std::cout &lt;&lt; "Open database successfully\n";
      }
      char *pSQL2[1];  
      pSQL2[0] = "Select * from Subscribers";
      rc = sqlite3_exec(db, pSQL2[0], callback, &amp;first, &amp;szErrMsg);
      if(rc != SQLITE_OK)
      {
          std::cout &lt;&lt; "SQL Error: " &lt;&lt; szErrMsg &lt;&lt; std::endl;
          sqlite3_free(szErrMsg);
          break;
      }
      else
      {
          printf("count: %s\n", first.ids);
      }
  }
  
  </code></pre>