#if defined(_WIN32) || defined(_WIN64) #include #endif #include #include #include static void test_error(MYSQL *mysql, int status) { if (status) { printf("Error: %s (errno: %d)\n", mysql_error(mysql), mysql_errno(mysql)); exit(1); } } int main() { MYSQL *mysql,*sock; MYSQL_RES *res; MYSQL_FIELD *field; unsigned int tab_charsetnr= 0; mysql= mysql_init(NULL); mysql_options(mysql, MYSQL_OPT_NAMED_PIPE, 1); if (!(sock = mysql_real_connect(mysql, ".", "***********", "*********", "test", 3306, NULL, 0))) { printf("Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); exit(1); } /* Checking the table */ if(mysql_query(sock, "SHOW VARIABLES LIKE '%timeout'")) { printf("Query error!\n%s\n\n", mysql_error(mysql)); exit(1); } res= mysql_store_result(sock); while(field = mysql_fetch_field(res)) { printf("field name %s\n", field->name); printf("\n\n"); } mysql_free_result(res); mysql_close(sock); return 0; }