下面貼一個mysql的庫,叫做dmysql 解壓縮以后,make ; make install 安裝 然后編譯程序的時候,包含dmysql.h頭文件,加上 -ldmysql標識,即可
頭里面定義了一個mysql數(shù)據(jù)庫的結構體,
typedef struct _dmysql_info { char *host; /*host for database*/ char *user; /*user name for database*/ char *pswd; /*password to the account*/ char *dbbs; /*name of database*/ } dmysql_info;
int main( void ) { dmysql_info db; db.host="127.0.0.1"; /*host for database*/ db.user="root"; /*user name for database*/ db.pswd=""; /*password to the account*/