摘要: #include <iostream>#include <string.h>#include <stdio.h>#include <map>using namespace std;typedef map <int ,string> templatemap;templatemap testmap;templatemap::iterator Find(int nID){return testmap.find(nID);}string GetElement(int nID){templatemap::iterator iter = Find 阅读全文
posted @ 2011-10-18 17:34 byfei 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 例子: string s, ss; . s = "The rain in Spain falls mainly in the plain."; ss = s.substr(12, 5); //Spain s.substr(12) //Spain falls mainly in the plain. 阅读全文
posted @ 2011-10-18 10:44 byfei 阅读(187) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <string.h>#include <stdio.h>using namespace std;void main(){ string test;char szBuffer[1024] = {0};char szBuffer02[1024] = {0};int a=1;int b=2;int c=3;sprintf(szBuffer,"%d,%d,%d",a,b,c );sprintf(szBuffer02,"%d,%d",a,b );test += szBuff 阅读全文
posted @ 2011-10-14 21:21 byfei 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 1. #include #include #include using namespace std;void main(){ string test; char szBuffer[1024] = {0}; char szBuffer02[1024] = {0}... 阅读全文
posted @ 2011-10-14 21:21 byfei 阅读(32) 评论(0) 推荐(0) 编辑
摘要: //需要设置为你自己的//在DBMS中线要创建数据库test,table bintest,data字段数据类型用LONGBLOB即可测试//测试文件c:\\test.iso,你可以找任何一个文件修改为即可,我找的是一个exe程序,修改为test.iso而已//最大测试过加入文件大小为650M(一个正真的iso文件)//注意:还要修改my.ini文件中的max_allowed_packet字段,我设置的是//max_allowed_packet = 1024M//#define host "localhost" //mysql server//#define username 阅读全文
posted @ 2011-10-14 19:51 byfei 阅读(193) 评论(0) 推荐(0) 编辑
摘要: mysql中,当使用的数据类型是longblob时,如何实现流式的读写,即每次读出或写入一块数据,分多次操作。一般的游标函数明显是无法完成这个需求的,从mysql.h中看其实现就明白了://典型的查询的代码如下int Query(const char* sql, int len, vector< vector<string> >& out){ if (0!=mysql_real_query(&m_client, sql, len)) { m_ErrorCode = (int)mysql_errno(&m_client); ERR_LOG(&quo 阅读全文
posted @ 2011-10-14 19:49 byfei 阅读(2781) 评论(0) 推荐(0) 编辑
摘要: int snprintf(char *str, size_t size, const char *format, ...); 将可变个参数(...)按照format格式化成字符串,然后将其复制到str中 (1) 如果格式化后的字符串长度 < size,则将此字符串全部复制到str中,并给其后添加一个字符串结束符('\0'); (2) 如果格式化后的字符串长度 >= size,则只将其中的(size-1)个字符复制到str中,并给其后添加一个字符串结束符('\0') 函数返回值:若成功则返回欲写入的字符串长度,若出错则返回负值。 例子:char *pB 阅读全文
posted @ 2011-10-14 19:08 byfei 阅读(597) 评论(0) 推荐(0) 编辑
摘要: 从一个字符串中读进与指定格式相符的数据. 例子: #define COMPRESS_PET "%d,%d,%d,%d,%d,%d,%ld,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%... 阅读全文
posted @ 2011-10-14 19:04 byfei 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 从一个字符串中读进与指定格式相符的数据.例子:#define COMPRESS_PET "%d,%d,%d,%d,%d,%d,%ld,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d" int nID = 0;int nRoleID = 0;int nSpeciesID = 0;int nGrade = 0;int nCharacter = 0;int nExp = 0;time_t nBirthday = 0;int nHp = 0;int nGrowRate 阅读全文
posted @ 2011-10-14 19:03 byfei 阅读(184) 评论(0) 推荐(0) 编辑
摘要: //需要设置为你自己的 //在DBMS中线要创建数据库test,table bintest,data字段数据类型用LONGBLOB即可测试 //测试文件c:\\test.iso,你可以找任何一个文件修改为即可,我找的是一个exe程序,修改为test.iso而已 //最大测试过加入... 阅读全文
posted @ 2011-10-14 17:01 byfei 阅读(2497) 评论(0) 推荐(0) 编辑