C++学习备忘
文章平均质量分 60
iteye_11190
这个作者很懒,什么都没留下…
展开
-
VC++ 编译libcurl 支持SSL,GZIP
由于网上下载的 libcurl 不支持 gzip,只好自己动手编译,期间走了很多弯路,下面是最终成功的记录。我所使用的环境 Visual Studio 2010 、 Windows 7 64 bit1 下载文件1.1 libcurl 下载页面 http://curl.haxx.se/download.html下载地址 http://curl.haxx.se/do...原创 2012-07-12 22:58:27 · 312 阅读 · 0 评论 -
jsoncpp 简明学习(含类似php的print_r函数)
C++ 处理JSON学习记录,今天整理了一下,把测试代码全文发上来。JSONCPP 官方地址:http://jsoncpp.sourceforge.net/ // study_json.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <json/json.h>#include <string>...原创 2012-06-30 12:59:43 · 252 阅读 · 0 评论 -
C/C++ 文件读写操作
标准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 = ...2012-06-25 00:09:27 · 122 阅读 · 0 评论 -
C++ 字符串操作学习
为什么std::string 连最常用,最基本的功能也没有呢?简直是让人无语!标准C++ 字符串处理增强函数://标准C++ string 去除首尾空白字符 2012-8-12 By Deweistatic inline void stringTrim(string &str){ //去除左侧空白符 for (std::string::iterator it...原创 2012-06-24 17:05:06 · 71 阅读 · 0 评论 -
char*, string, CString, String^的相互转换
从char*转换: char *chars = "Hello";从char*到string: string s(chars);从char*到CString: CString s(chars);从char*到String^: String ^s = gcnew String(chars); 从stri...原创 2012-06-23 14:17:47 · 159 阅读 · 0 评论 -
C风格日期时间在std c++中使用备忘
//包含的头文件#include <ctime>#include <iostream>#include <iomanip> /*{{{ 显示100个月前的时间 */ std::time_t now = std::time(NULL); std::tm tm = *std::localtime(&now);//Unix时间戳转...原创 2013-10-25 17:47:29 · 164 阅读 · 0 评论 -
查找HTML代码“超级链接”中含有域名的函数
需求:在一段HTML里寻找超级链接中(正文文本)域名。 例如HTML内容如下:<div id="bdfs0" class="EC_im EC_fr EC_PP EC_idea1017 "><a id="dfs0" class="EC_t EC_BL" onmousedown="return c({'fm':'im','title':this.innerHTML原创 2013-10-22 17:48:43 · 402 阅读 · 0 评论 -
纯C实现MD5加密
序 真是天下文章一大抄,国内的牛人们在抄国外的开源项目,而小白们就在抄这些牛人的博客。在写这篇文章的时候,上网查了一下,才发现已经有很多牛人用中文翻译了类似的PHP的md5源码。 我从php源码5.2.17中提取并封装的MD5类代码如下:zmd5.h/* 这个类是通用MD5加密 by Dewei 2013-10-21 用法: #include "zmd...原创 2013-10-21 11:17:48 · 322 阅读 · 0 评论 -
libcurl 编译支持gzip、ssl、c-ares
使用CURLOPT_NOSIGNAL后必须启用异步DNS,因此需要重新编译libcurl,使其支持c-ares。curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);//禁用掉alarm信号,防止多线程中使用超时崩溃curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1L); //禁掉alarm后会有大量CLOSE...原创 2013-10-17 08:50:04 · 975 阅读 · 1 评论 -
VC获取windows 安装内存(RAM)
//起因:在某些机器上无法使用GlobalMemoryStatusEx和GlobalMemoryStatus获取到正确的总内存大小//可使用GetPhysicallyInstalledSystemMemory获取到。//该函数只支持windows vista/7/8/server 2008/ server 2012std::string s;s.resize(64);ULO...原创 2013-10-11 16:10:56 · 400 阅读 · 0 评论 -
Visual Studio 2010/2013 string对UTF8的支持总结
VisualStudio 2010 SP1环境 1、设置string默认编码为utf8,只需要在文件头部加入以下代码#pragma execution_character_set("utf-8") //默认使用UTF8 2、debug提示窗口显示utf8,打开C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\...原创 2013-09-12 00:13:19 · 361 阅读 · 0 评论 -
stringstream 的.str()正确用法和清空操作
streamstring在调用str()时,会返回临时的string对象。而因为是临时的对象,所以它在整个表达式结束后将会被析构。如果需要进一步操作string对象,先把其值赋给一个string变量后再操作。 stringstream ss("012345678901234567890123456789012345678901234567890123456789"); //错误用法...原创 2013-09-11 14:53:56 · 1316 阅读 · 0 评论 -
C语言实现 strpos 查找字符串首次出现位置
今天又写了个函数,查找字符串首次出现位置,以此作为记录:/* {{{ 查找字符串首次出现的位置,没有找到返回 -1,两个字符串相等返回 0 在GCC下使用C99: int strpos(const char *haystack,const char *needle, _Bool ignorecase = 0) _Bool ignorecase =1 忽略大小写 ...原创 2012-08-17 19:50:44 · 1815 阅读 · 0 评论 -
C/C++ 字符串为空判断 效率比较
为了测试判断字符串为空的效率,今天特意做了一个测试。得出以下结论: Cstring s = "我是一个中国人!";s.GetLength() == 0 效率略快于 s.IsEmpty(),但是 s[0] == '\0' 效率比 GetLength() 低一倍。 换成 string 又测了一次://string s.length() 2730 毫秒//string s....原创 2012-08-16 19:22:33 · 737 阅读 · 0 评论 -
C/C++ URL编码,解码(提取自PHP)
偶然发现,网上已经有很多对PHP的URL编解码函数提取的文章,但我还是想自己提取一次。看到网上那些文章,居然还保留着无用的代码片段,例如:os_toassii 那一段。 URL解码函数:/* {{{ php_htoi */static int php_htoi(char *s){ int value; int c; c = ((unsigned char...原创 2012-08-13 23:59:35 · 200 阅读 · 0 评论 -
VC++调用libcurl的VC库使用详解
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.hax...原创 2012-06-30 17:11:25 · 303 阅读 · 0 评论