title: segmentation fault when connecting to mysql database with c
body: <p>Does anyone know why the following would cause a segmentation fault when run?</p>
  
  <pre><code>#include &lt;mysql.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  void main(void)
  {
      printf("MySQL client version : %s\n", mysql_get_client_info());
      MYSQL *conn=NULL;
      mysql_init(conn);
      char *server = "localhost";
      char *user = "root";
      char *password = "pass";
      char *database = "weather";
      char *table ="room_temp";
      char *tst_qry="INSERT INTO `weather`.`room_temp` (`idx`, `date`, `temperature`) VALUES (NULL, CURRENT_TIMESTAMP, '10')";
  
          mysql_real_connect(conn, server, user, password, database, 0, NULL, 0);
  
  
  }
  </code></pre>
  
  <p>I complied as follows</p>
  
  <pre><code>gcc -o mysql $(mysql_config --cflags) mysql.c $(mysql_config --libs)
  </code></pre>
  
  <p>The output was as follows,</p>
  
  <pre><code>MySQL client version : 5.5.31
  Segmentation fault
  </code></pre>
  
  <p>Please help!</p>