gpt4 book ai didi

mysql - C程序中的"unable to include mysql.h"

转载 作者:太空宇宙 更新时间:2023-11-04 07:35:29 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How to make #include <mysql.h> work?

我需要连接C和mysql

这是我的程序

#include <stdio.h>
#include <mysql.h>
#define host "localhost"
#define username "root"
#define password "viswa"
#define database "dbase"
MYSQL *conn;

int main()
{

MYSQL_RES *res_set;
MYSQL_ROW row;

conn = mysql_init(NULL);

if( conn == NULL )
{ `
printf("Failed to initate MySQL\n");
return 1;
}


if( ! mysql_real_connect(conn,host,username,password,database,0,NULL,0) )
{
printf( "Error connecting to database: %s\n", mysql_error(conn));
return 1;
}

unsigned int i;


mysql_query(conn,"SELECT name, email, password FROM users");


res_set = mysql_store_result(conn);


unsigned int numrows = mysql_num_rows(res_set);
unsigned int num_fields = mysql_num_fields(res_set);



while ((row = mysql_fetch_row(res_set)) != NULL)
{

for(i = 0; i < num_fields; i++)
{
printf("%s\t", row[i] ? row[i] : "NULL");
}
printf("\n");

}


mysql_close(conn);
return 0;

}

我收到错误“无法包含 mysql.h”。

我正在使用 Windows 7、Turbo C、mysql,我下载了 mysql-connector-c-noinstall-6.0.2-win32-vs2005,但我不知道如何包含它。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com