#include <stdlib.h>
#include <mysql/mysql.h>
int main(int argc, char *argv[])
{
MYSQL *my_con = malloc( sizeof(MYSQL) )
MYSQL_RES *my_res
MYSQL_FIELD *my_field
MYSQL_ROW my_row
int rows, i
int res
int a[2] = {51,2}
printf("%3d ",a[0])
mysql_init(my_con)
my_con = mysql_real_connect(my_con, "localhost", "root", "jwn.com",
"jwn", 0, NULL, CLIENT_FOUND_ROWS)
if( NULL == my_con )
error_quit("Connection fail", my_con)
printf("Connection success\n")
res = mysql_query(my_con,
"insert into class1(name, age, birthday) value('abc', 52, NOW())")
mysql_free_result(my_res)
mysql_close(my_con)
free(my_con)
return 0
}
你的i_query是生成SQL文本文件吗,反复调用fprintf(i_query, "INSERT INTO stock_data values(%.2f,%.2f,%.2f)",v1,v2,v3)可以在文件中生成多行INSERT INTO语句,可以插入多行,但是你多个SQL语句之间应该有分号,你的这个语句可以修改如下:fprintf(i_query, "INSERT INTO stock_data values(%.2f,%.2f,%.2f)\n",v1,v2,v3)
#include "stdio.h"void main()
{int i
int a[5]
for(i=0i<5i++)
{scanf("%d",&a[i])
}
printf("%d",a[3])
}
这是一个例子。自己看看吧
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)