unabel将mysql.h包含在C程序中 [英] unabel to include mysql.h in c program
本文介绍了unabel将mysql.h包含在C程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要连接c和mysql
这是我的程序
I need to connect c and mysql
this is my program
#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;
}
我收到错误消息"unabel包括mysql.h"
我正在使用Windows 7,Turbo C,MySQL,并且我下载了mysql-connector-c-noinstall-6.0.2-win32-vs2005,但不知道如何包含它
谢谢
i got error "unabel to include mysql.h"
i am using windows 7, turbo c, mysql and i downloaded mysql-connector-c-noinstall-6.0.2-win32-vs2005, but dont know how to include it
thank you
推荐答案
它不知道在哪里找到mysql.h
.
您应该添加包含以下内容的文件夹mysql.h
文件到编译器的include搜索路径.
You should add the folder containing the mysql.h
file to the include search path of your compiler.
include语句的语法不正确,缺少分隔符,应为:
The syntax of your include statements is incorrect, it''s missing the delimiters, it should be:
#include <mysql.h>
// or
#include "mysql.h"
取决于系统中的mysql.h
是包含目录还是项目目录之一.
depending on whether mysql.h
is in the system include directories or one of the project directories.
这篇关于unabel将mysql.h包含在C程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文