易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

查找字符串中字符不重复的最大子串(C/C++)

 //输入参数:*str 搜索字符串
// subStrLen 用于返回找到的最大子字符串长度
//返回:找到的最大子字符串指针
char * findMaxSubStr(char *str, int &subStrLen){
char *subStr;
char *p = str;
int index[256] ;
for (int ix = 0; ix < sizeof(index)/sizeof(index[0]); ix++)
{
in ......

Linux下用eclipse写C/C++语言程序的编译问题

当要建立线程等时,在Linux下,用文本编辑,在键入“g++ -lpthread”.......“可以把库pthread引入”,编译通过。现在想用eclipse,但是默认情况下,引入不了pthread。会报“undefined reference to phread_create”等错误。
解决方法:可以在project中好到properties
在里面的&ldquo ......

Linux下通用线程池的创建与使用 C++

本文给出了一个通用的线程池框架,该框架将与线程执行相关的任务进行了高层次的抽象,使之与具体的执行任务无关。另外该线程池具有动态伸缩性,它能根据执行任务的轻重自动调整线程池中线程的数量。文章的最后,我们给出一个简单示例程序,通过该示例程序,我们会发现,通过该线程池框架执行多线程任务是多么的简单。
&nb ......

C/C++与Java函数重载区别!

#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 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号