c++ mysql
/*
* test.cpp
*
* Created on: 2010-5-13
* Author: Sarah
*/
#include "/usr/include/mysql/mysql.h" /*Ϊ¾ø¶Ô·¾¶*/
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;
int main(int argc,char *argv[])
{
char *user = "root", *pwd = "475475", *dbname = "bookman";
MYSQL mysql;
MYSQL_RES *mysql_ret;
MYSQL_ROW mysql_row;
unsigned long num_rows;
int ret;
mysql_init(&mysql);
if(mysql_real_connect(&mysql,NULL,user,pwd,dbname,0,NULL,0))
{
printf("Connection success!\n");
//sql×Ö·û´®
string sqlstr;
sqlstr ="INSERT INTO booklist VALUES (3,'friend','Jack',2,1);";
if(0==mysql_query(&mysql,sqlstr.c_str()))
{
cout<<"mysql_query() insert data succeed"<<endl;
}
else
{
cout<<"mysql_query() insert data failed"<<endl;
return -1;
}
ret = mysql_query(&mysql,"select * from booklist");
if(!ret)
{
printf("Query Success!\n");
mysql_ret = mysql_store_result(&mysql);
if(mysql_ret != NULL)
{
printf("Store Result Success!\n");
num_rows = mysql_num_rows(mysql_ret);
if(num_rows &n
Ïà¹ØÎĵµ£º
ת×Ô£ºhttp://blog.csdn.net/xiaocai0001/archive/2006/04/14/662921.aspx
static¹Ø¼ü×ÖÊÇC, C++Öж¼´æÔڵĹؼü×Ö, ËüÖ÷ÒªÓÐÈýÖÖʹÓ÷½Ê½, ÆäÖÐÇ°Á½ÖÖÔÚC/C++ÓïÑÔÖÐʹÓÃ, µÚÈýÖÖÖ»ÔÚC++ÖÐʹÓÃ(C,C++ÖоßÌåϸ΢²Ù×÷²»¾¡Ïàͬ, ±¾ÎÄÒÔC++Ϊ׼).
(1)¾Ö²¿¾²Ì¬±äÁ¿
(2)Íⲿ¾²Ì¬±äÁ¿/º¯Êý
(3)¾²Ì¬Êý¾Ý³ÉÔ±/³ÉÔ±º¯Êý
ÏÂÃæ¾ÍÕâÈ ......
GCC ÖÐÎÄÊÖ²á
¡¡¡¡http://www.nbfan.com/forum/dispbbs....&ID=1433&page=1
¡¡¡¡GNU make Ö¸ÄÏ
¡¡¡¡http:/ ......
±¾Îĸø³öÁËÒ»¸öͨÓõÄÏ̳߳ؿò¼Ü£¬¸Ã¿ò¼Ü½«ÓëÏß³ÌÖ´ÐÐÏà¹ØµÄÈÎÎñ½øÐÐÁ˸߲ã´ÎµÄ³éÏó£¬Ê¹Ö®Óë¾ßÌåµÄÖ´ÐÐÈÎÎñÎ޹ء£ÁíÍâ¸ÃÏ̳߳ؾßÓж¯Ì¬ÉìËõÐÔ£¬ËüÄܸù¾ÝÖ´ÐÐÈÎÎñµÄÇáÖØ×Ô¶¯µ÷ÕûÏ̳߳ØÖÐÏ̵߳ÄÊýÁ¿¡£ÎÄÕµÄ×îºó£¬ÎÒÃǸø³öÒ»¸ö¼òµ¥Ê¾Àý³ÌÐò£¬Í¨¹ý¸ÃʾÀý³ÌÐò£¬ÎÒÃǻᷢÏÖ£¬Í¨¹ý¸ÃÏ̳߳ؿò¼ÜÖ´ÐжàÏß³ÌÈÎÎñÊǶàôµÄ¼òµ¥¡£
&nb ......
50¸öc/c++Ô´´úÂëÍøÕ¾
ÎÄÕ³ö´¦£ºhttp://blog.chinaunix.net/u3/106835/showart_2190632.html
C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ¡£ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾ºÍÍøÒ³Çåµ¥£¬ÕâЩÍøÕ¾Ìṩc/c++Ô´´úÂë
¡£Õâ·ÝÇåµ¥ÌṩÁËÔ´´úÂëµÄÁ´½ÓÒÔ¼°ËüÃǵÄС˵Ã÷¡£ÎÒÒѾ¡Á¦°üÀ¨×î¼ÑµÄC/C++Ô´´úÂëµÄÍøÕ¾¡£Õâ²»ÊÇÒ»¸öÍêÕûµÄÇåµ¥£¬ÄúÓн¨Òé¿ÉÒÔÁªÏµÎÒ£¬ ......
LinuxϽøÐÐMYSQLµÄC++±à³ÌÆð²½ÊÖ¼Ç
Ê×ÏÈ°²×°±ØÐèµÄ¿ª·¢°ü
sudo apt-get install gcc g++ libgcc1 libg++ make gdb
°²×°MYSQLµÄCÓïÑÔ¿ª·¢°ü
sudo apt-get install libmysql++-dev libmysql++2c2a libmysqlclient15-dev libmysqlclient15off
......