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

C/C++ std::string 切词

用了三种方法...
#if 0
void StringTokenize(const std::string& strSrc, const std::string& strDelimit, std::vector<std::string>& vecSub)
{
if (strSrc.empty() || strDelimit.empty())
{
throw "tokenize: empty string\n";
}
vecSub.clear();

std::size_t nCurPos = 0;
std::size_t nNextPos = 0;
while ((nNextPos = strSrc.find_first_of(strDelimit, nCurPos)) != std::string::npos)
{
if (nNextPos - nCurPos > 0)
{
vecSub.push_back(strSrc.substr(nCurPos, nNextPos - nCurPos));
}
nCurPos = nNextPos + 1;
}
// Add the last one
std::string strLast = strSrc.substr(nCurPos);
if (!strLast.empty())
vecSub.push_back(strSrc.substr(nCurPos));
}
void StringToken(char *strToken, const char *strDelimit, std::vector<std::string>& vecSub)
{
assert(strToken && strDelimit && "Token, Delimit can not be NULL");
vecSub.clear();
char *pToken = strToken;
char *pNextToken = NULL;
pToken = strtok_s(pToken, strDelimit, &pNextToken);
while (pToken != NULL)
{
vecSub.push_back(pToken);
pToken = strtok_s(NULL, strDelimit, &pNextToken);
}
}
#endif
void StringTokenize(const std::string& strSrc, const std::string& strDelimit, std::vector<std::string>& vecSub)
{
if (strSrc.empty() || strDelimit.empty())
{
throw "tokenize: empty string\n";
}
vecSub.clear();
std::size_t nCurPos = 0;
std::size_t nNextPos = 0;
while ((nCurPos = strSrc.find_first_not_of(strDelimit, nNextPos)) != std::string::npos)
{
nNex


相关文档:

转载:Hadoop 应该用C++实现,而不是Java

http://www.trendcaller.com/2009/05/hadoop-should-target-cllvm-not-java.html
Sunday, May 10, 2009
Hadoop should target C++/LLVM, not Java (because of watts)
< type="text/javascript">
digg_url="http://www.trendcaller.com/2009/05/hadoop-should-target-cllvm-not-java.html";
Over the years, ......

Optimizing Your C/C++ Applications


C/C++ optimizing compilers are great--but there *are* a few techniques for hand-tuning your code to run as efficiently as possible on the AMD Athlon64 and Opteron processors, especially when developing DLLs, device drivers, or other performance-bound pieces of code.
Alan Zeichick  
Share | ......

[VC]函数调用约定解析(C/C++)

C/C++函数调用约定和函数名称修饰规则探讨
作者:星轨(oRbIt)
 
使用C/C++语言开发软件的程序员经常碰到这样的问题:有时候是程序编译没有问题,但是链接的时候总是报告函数不存在(经典的LNK
2001错误),有时候是程序编译和链接都没有错误,但是只要调用库中的函数就会出现堆栈异常。这些现象通常是出现在C和C ......

C语言编写linux下的守护进程

利用
下载的这段代码,成功实现了守护进程,原来守护进程是很简单的事情。
  在main函数中执行
  init_daemon();//初始化为Daemon
  就可以把进程变成守护进程
  
#include
#include
#include
#include
#include
void
 init_daemon(void
)
{
int
 pid;
int
 i;
if
(pid=fork()) ......

C/C++中的64位整数(__int64 and long long)

  在做ACM题时,经常都会遇到一些比较大的整数。而常用的内置整数类型常常显得太小了:其中long 和 int
范围是[-2^31,2^31),即-2147483648~2147483647。而unsigned范围是[0,2^32),即
0~4294967295。也就是说,常规的32位整数只能够处理40亿以下的数。
  那遇到比40亿要大的数怎么办呢?这时就要用到C++的64位扩展 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号