`
dewei
  • 浏览: 163205 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论
文章列表
为了测试判断字符串为空的效率,今天特意做了一个测试。得出以下结论:   Cstring s = "我是一个中国人!";s.GetLength() == 0 效率略快于 s.IsEmpty(),但是  s[0] == '\0' 效率比 GetLength() 低一倍。   换成 string 又测了一次: //string s.length() 2730 毫秒 //string s.empty() 2839 毫秒 //string s[0] 5616 毫秒结论:标准C++的 string 真让人失望,效率如此低下!!虽然 CString 受限于MFC,但还是值 ...
偶然发现,网上已经有很多对PHP的URL编解码函数提取的文章,但我还是想自己提取一次。看到网上那些文章,居然还保留着无用的代码片段,例如:os_toassii 那一段。   URL解码函数: /* {{{ php_htoi */ static int php_htoi(char *s) { int value; int c; c = ((unsigned char *)s)[0]; if (isupper(c)) c = tolower(c); value = (c >= '0' && c <= '9' ? c - '0 ...
由于网上下载的 libcurl 不支持 gzip,只好自己动手编译,期间走了很多弯路,下面是最终成功的记录。 我所使用的环境 Visual Studio 2010 、 Windows 7 64 bit 1 下载文件 1.1 libcurl 下载页面 http://curl.haxx.se/download.html 下载地址 htt ...
1、下载官方库。 地址:http://curl.haxx.se/download.html#Win32  下载  Win32 - MSVC,下面有两个版本的库,一个是带ssl的,一个是不带ssl的。 不带ssl的:http://curl.haxx.se/download/libcurl-7.18.0-win32-msvc.zip 带ssl的:http://curl.haxx.se/download/libcurl-7.19.3-win32-ssl-msvc.zip   2、在VS2010中VC++目录中加入从zip中解压的include目录,和lib目录   3 ...
C++ 处理JSON学习记录,今天整理了一下,把测试代码全文发上来。 JSONCPP 官方地址:http://jsoncpp.sourceforge.net/   // study_json.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <json/json.h> #include <string> #if defined(_MSC_VER) && _MSC_VER >= 1310 # pragma warning( disable: 4996 ...
  标准C++ 读写文件内容: //标准C++ 读文件内容 ( 仿PHP ) 2012-8-12 by Dewei //用法:string s = file_get_contents("C:\\LICENSE.txt"); string file_get_contents(const string &filename) { string contents = ""; fstream in; in.open(filename.c_str(), fstream::in|fstream::binary|fstream ...
为什么std::string 连最常用,最基本的功能也没有呢?简直是让人无语! 标准C++ 字符串处理增强函数: //标准C++ string 去除首尾空白字符 2012-8-12 By Dewei static inline void stringTrim(string &str) { //去除左侧空白符 for (std::string::iterator iter = str.begin(); iter != str.end(); ++iter) { if (!isspace(static_cast<unsigned char>(*i ...
从char*转换:         char *chars = "Hello"; 从char*到string:      string s(chars); 从char*到CString:   CString s(chars); 从char*到String^:   String ^s = gcnew String(chars);   从string转换          string str("Hello"); 从string到char*:      char chars[64] ...
Global site tag (gtag.js) - Google Analytics