Добрый день!
Изучаю MYSQL API
...
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <mysql/mysql.h>
...
MYSQL *my_conn;
MYSQL_RES *res_prt;
MYSQL_ROW sqlrow;
my_conn = mysql_init(NULL);
if (!my_conn) {
fprintf (stderr, "mysql_init failed\n");
return EXIT_FAILURE;
}
int res;
res = mysql_real_connect (&my_conn, DB_ADDR, DB_USER, DB_PASS, DB_NAME, DB_PORT, NULL, 0);
if (!my_conn) {
fprintf (stderr, "mysql_real_connect failed - can not connect\n");
return EXIT_FAILURE;
}
res = mysql_query (&my_conn, "SELECT value2 FROM ls_config WHERE param IS max_cs");
res_ptr = mysql_store_result (&my_conn);
printf ("Retrived %lu rows\n", (unsigned long) mysql_num_rows (res_ptr));
mysql_free_result (res_ptr);
mysql_close (&my_conn);
Компилирую вот так:
gcc -I/usr/include/mysql ls.c -L/usr/lib/mysql -o ls ls.o -lmysqlclient -lz
И получаю:
error: `res_ptr' undeclared (first use in this function)
error: (Each undeclared identifier is reported only once
error: for each function it appears in.)
с указанием на строку: res_ptr = mysql_store_result (&my_conn);