mysql++ linux

pradeep rawat (9)
how to print the result of the mysql querry in c++
myc codes are :
#include<iostream>
#include<mysql/mysql.h>
#include<stdio.h>
#define DATABASE "vobd_db"
using namespace std;
int main()
{
MYSQL_RES *result;
MYSQL *connect;
MYSQL_ROW row;
connect = mysql_init(NULL);
connect = mysql_real_connect(connect, "localhost", "root", "" ,
"database" ,0,NULL,0);
if (connect)
{
cout << "connected successfully\n";
}

mysql_query (connect," select * from obd_call_status limit 10 ");
if (result =mysql_store_result(connect));
{
cout << "result success \n";
}
row = mysql_fetch_row(result);
cout << row;
mysql_free_result(result);

mysql_close(connect);
return 0;

}
~

output :segmentation fault.
Last edited on
kbw (5520)
Where does it crash?

You don't check row for NULL.
pradeep rawat (9)
okay okay got it thanx
Topic archived. No new replies allowed.