主程序代码:#ifdefined(_WIN32)||defined(_WIN64)#include#endif#include#include#ifndef_mysql_h#define_mysql_h//#include"mysql.h"//#include
主程序代码:
#if defined(_WIN32) || defined(_WIN64)
#include
#endif
#include
#include
#ifndef _mysql_h
#define _mysql_h
//#include "mysql.h"
//#include
//#include
//#include
MYSQL mysql,*sock; //
MYSQL_RES *res; //
MYSQL_ROW row ; //
int main(void )
{
mysql_init(&mysql);
if(!(sock=mysql_real_connect(&mysql,"localhost","root","19890505","test",0,NULL,0)))
{
fprintf(stderr,"Couldn't connection to the engin",mysql_error(&mysql));
exit(0);
}
if(mysql_query(sock,"select * from info"))
{
fprintf(stderr,"Couldn't make a query!",mysql_error(sock));
exit(0);
}
if(!(res=mysql_store_result(sock)))
{
fprintf(stderr,"Couldn't make a resultSet!",mysql_error(sock));
exit(0);
}
while(row=mysql_fetch_row(res))
{
printf("id is :%s\nnumber is %s\ntypeinfo is %s\n",row[0],row[1],row[2]);
printf("********************\n\n");
}
mysql_free_result(res);mysql_close(sock);exit(0);
}
#endif
在同一文件夹里我放了如下的头文件:
my_alloc.h my_list.h mysql.h mysql_com.h mysql_time.h mysql_version.h typelib.h
编译的时候出现了如下错误:
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(12) : error C2061: syntax error : identifier 'mysql'
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(12) : error C2059: syntax error : ';'
C:\Users\bdg\Desktop\新建文件夹 (3)\1.c(12) : error C2059: syntax error : ','
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(13) : error C2143: syntax error : missing '{' before '*'
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(14) : error C2061: syntax error : identifier 'row'
C:\Users\bdg\Desktop\新建文件夹 (3)\1.c(14) : error C2059: syntax error : ';'
C:\Users\bdg\Desktop\新建文件夹 (3)\1.c(18) : warning C4013: 'mysql_init' undefined; assuming extern returning int
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(18) : error C2065: 'mysql' : undeclared identifier
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(19) : error C2065: 'sock' : undeclared identifier
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(19) : warning C4013: 'mysql_real_connect' undefined; assuming extern returning int
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(21) : warning C4013: 'mysql_error' undefined; assuming extern returning int
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(24) : warning C4013: 'mysql_query' undefined; assuming extern returning int
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(29) : warning C4013: 'mysql_store_result' undefined; assuming extern returning int
C:\Users\bdg\Desktop\新建文件夹 (3)\1.c(29) : warning C4047: '=' : 'int *' differs in levels of indirection from 'int '
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(34) : error C2065: 'row' : undeclared identifier
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(34) : warning C4013: 'mysql_fetch_row' undefined; assuming extern returning int
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(36) : error C2109: subscript requires array or pointer type
C:\Users\bdg\Desktop\新建文件夹(3)\1.c(36) : error C2109: subscript requires arr
……
错误出在哪里了?
展开