title: Segmentation fault (core dumped) on simple SQL code
body: <p>I get a “Segmentation fault (core dumped)” error on some simple C++ code. The error will accure when I use the variable result. What can cause this problem in this case? I know that something goes out of range, but how is it possible that result does? There are only 2 items in the database. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/variant.hpp&gt;
  #include &lt;mysql/mysql.h&gt;
  #include &lt;mysql_connection.h&gt;
  
  using namespace std;
  
  const char *server = "localhost";
  const char *user = "XXXX";
  const char *password = "XXXX";
  const char *database = "XXXX";
  
  int main()
  {
      MYSQL *conn;
      MYSQL_RES *result;
      MYSQL_ROW row;
  
      int num_fields = 0;
  
      conn = mysql_init(NULL);
      mysql_real_connect(conn, server,user, password, database, 0, NULL, 0);
  
      mysql_query(conn, "SELECT * FROM `users` WHERE `id` = '5'");
      result = mysql_store_result(conn);
  
      num_fields = mysql_num_fields(result);
  
      while ((row = mysql_fetch_row(result)))
      {
         cout &lt;&lt; "Spam ";
      }
  
      mysql_free_result(result);
      mysql_close(conn);
  }
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>Segmentation fault (core dumped)
  
  Process returned 139 (0x8B)   execution time : 0.255 s
  Press ENTER to continue.
  </code></pre>