For some reason I don’t know, the program crashes when it tries to execute
mysql_query(mysql,"CREATE TABLE writers(name VARCHAR(25))");
Though the query gets executed successfully and the table does get created , windows complain that the program stopped responding but it hasn’t.
Here’s my main function.
int main()
{
MYSQL* mysql;
mysql_init(mysql);
mysql_real_connect(mysql,"localhost","root","xxxx","test",0,NULL,0);
mysql_query(mysql,"CREATE TABLE writers(name VARCHAR(25))"); // 'Program stops responding' without actually crashing.
mysql_close(mysql);
getchar();
return 0;
}
Your use of the API is wrong, you’re passing a dangling pointer to
mysql_initand not checking a single return value. Don’t do that.You can transform your code like this: