Hello Konstantin,
this code is buggy, because 'new' is not a valid C operator.
And MYSQL is a struct not an object.
The 'new' operator allocates memory for objects (C++).
In C you?ve to use the malloc function.
Take a look at the libmysqltest example, which comes with your distribution.
Regard
Konstantin Osipov writes:
> Hi All!
>
> Is this code buggy?
> --
> MYSQL* mysql = new MYSQL;
>
> mysql_init(mysql);
>
> mysql_real_connect(mysql, "localhost");
> /* some work*/
> mysql_close(mysql);
> mysql_real_connect(mysql, "otherhost");
> /* some work*/
> mysql_close(mysql);
Hi All!
Is this code buggy?
--
MYSQL* mysql = new MYSQL;
mysql_init(mysql);
mysql_real_connect(mysql, "localhost");
/* some work*/
mysql_close(mysql);
mysql_real_connect(mysql, "otherhost");
/* some work*/
mysql_close(mysql);
delete mysql;
--
In other words, if struct MYSQL allocated manually,