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
相关文档:
我用的是ubuntu操作系统。打开终端
1.sudo apt-get install vim(vim-full 这个软件自9.10版本被废弃了,不论怎么添加软件源都找不到的,所以直接安装vim就可以了,,也可以安装gvim,,在新立得软件里面搜索vim就可以找到了)
2.
sudo apt-get install build-essential // build-essential是c语言的开发包,包含了gcc ma ......
当要建立线程等时,在Linux下,用文本编辑,在键入“g++ -lpthread”.......“可以把库pthread引入”,编译通过。现在想用eclipse,但是默认情况下,引入不了pthread。会报“undefined reference to phread_create”等错误。
解决方法:可以在project中好到properties
在里面的&ldquo ......
http://www.gamedev.net/reference/programming/features/orgfiles/page2.asp
通过四个pitfall讲解头文件的由来和好处,以及使用头文件定义inline func and template.
Remember that, as far as the compiler is concerned, there is absolutely no difference between a header file and a source file.
The key idea ......
#include <iostream>
using namespace std;
class Base {
public:
virtual void fn(int x) {
cout << "In Base class, int x = " << x << endl;
}
};
class SubClass : public Base {
public:
// 函数的重载,这样的重载方式,在Java中能行,在C/C++中却不行
virt ......
上一次用linux是2002年用kdevelop及qt库开发多媒体软件。
时隔8年再一次在linux下搞开发,依然菜鸟,还是生疏。
感觉自己的大脑的存储空间,随着年龄的增加在变小,很多弄过的,又只能从头学起。
不过有句话“活到老,学到老”哈!
惭愧,惭愧。
1、编写动态库的c++文件
cvpnlib.cpp cv ......