#if defined(_WIN32) || defined(WIN32) || defined(_WIN64) #include #endif #include #include #include "mysql.h" #define SELECT_QUERY "select name from test where num = %d" int main(int argc, char **argv) { int count, num; MYSQL mysql,*sock; MYSQL_RES *res; char qbuf[160]; MYSQL_FIELD *sql_field; char *szUser = "root"; char *szPass = ""; mysql_init(&mysql); if (!(sock = mysql_real_connect(&mysql, "localhost", szUser, szPass, "thoga", 0, NULL, 0))) { fprintf(stderr,"Couldn't connect to engine!\n%s\n\n",mysql_error(&mysql)); perror(""); exit(1); } mysql.reconnect= 1; count = 0; res = mysql_list_fields(&mysql, "xyz", NULL); sql_field=mysql_fetch_field(res); printf("Field name: %s, Table name: %s", sql_field->name, sql_field->table); mysql_free_result(res); mysql_close(sock); exit(0); return 0; /* Keep some compilers happy */ }