You have to call mysql_init() prior to mysql_real_connect().
Since you don't, you're passing garbage as the first argument
to mysql_real_connect().
You also don't check whether or not mysql_real_connect(),
mysql_query(), or mysql_store_result() succeed or fail.
It would be a good idea to add some error checking, or
you're going to make it hard to track down any other problems
you may have.
At 11:17 PM +0300 2000-01-30, Indeyets wrote:
>#include<mysql.h>
>#include<iostream>
>using namespace std;
>
>int main(void)
>{
> MYSQL *connection;
> MYSQL_RES *result;
> MYSQL_ROW row;
>
> connection = mysql_real_connect(connection, NULL, NULL,
>NULL, "mysql", 3306, NULL, 0);
> mysql_query(connection, "select * from user");
> result = mysql_store_result(connection);
> while(row = mysql_fetch_row(result))
> {
> cout << row[0];
> }
> mysql_close(connection);
> exit(0);
>}
--
Paul DuBois, paul@stripped