Using mysql with C language.
时间:2008-11-25 来源:longtem
Table: contact
Table content:
mysql> select * from contact;
+--------+----------------+--------+-------+------------+-----------------------------------------------------------------+
| name | email | tel | qq | birthday | note |
+--------+----------------+--------+-------+------------+-----------------------------------------------------------------+
| Petter | [email protected] | 12345 | 54321 | 2008-11-14 | Loves sweet very much! |
| Marry | [email protected] | 13456 | 65431 | 2008-03-05 | Hates Sanlu milk powder! |
| Jack | [email protected] | 13221 | 3422 | 2007-10-02 | Has been in Heaven because of the magic powder mentioned above! |
| Rose | [email protected] | 343232 | 2321 | 2007-12-08 | Jack's lover. Suffering from the damn powder |
+--------+----------------+--------+-------+------------+-----------------------------------------------------------------+
4 rows in set (0.01 sec)
Want to fetch the content.
Code:
See below.
Compiling command:
gcc -lmysqlcliet my.c -o query
Running result:
================================================
Name: Petter
Email: [email protected]
Tel: 12345
QQ: 54321
Birthday: 2008-11-14
Note: Loves sweet very much!
================================================
================================================
Name: Marry
Email: [email protected]
Tel: 13456
QQ: 65431
Birthday: 2008-03-05
Note: Hates Sanlu milk powder!
================================================
================================================
Name: Jack
Email: [email protected]
Tel: 13221
QQ: 3422
Birthday: 2007-10-02
Note: Has been in Heaven because of the magic powder mentioned above!
================================================
================================================
Name: Rose
Email: [email protected]
Tel: 343232
QQ: 2321
Birthday: 2007-12-08
Note: Jack's lover. Suffering from the damn powder
================================================
Code:
#include <stdio.h>
|