随笔分类 -  C/C++

摘要:在C++中可以new一个长度为0的数组,通过下面的语句: char* p = new char[0]; 指针p中保存一个非NULL的地址,但是你不能够对p指向的内存进行写入,因为p的内存长度为0, 该指针也可以通过语句delete [] p 删除掉。 注意:如果不幸往p中写入数据,如: memcpy 阅读全文
posted @ 2016-03-10 20:38 godjob 阅读(1856) 评论(0) 推荐(0)
摘要:A Cross-Platform Memory Leak DetectorMemory leakage has been a permanent annoyance for C/C++ programmers. Under MSVC, one useful feature of MFC is rep... 阅读全文
posted @ 2015-05-28 09:47 godjob 阅读(435) 评论(0) 推荐(0)
摘要:Boost - Provides a repository for free peer-reviewed portable C++ source libraries. The emphasis is on libraries which work well with the C++ standard 阅读全文
posted @ 2014-10-15 19:05 godjob 阅读(625) 评论(0) 推荐(0)
摘要:http://blog.sina.com.cn/s/blog_7632c6010100u1et.htmlhttp://www.codeproject.com/Tips/197097/Converting-ANSI-to-Unicode-and-backhttp://www.codeproject.c... 阅读全文
posted @ 2014-10-10 16:46 godjob 阅读(210) 评论(0) 推荐(0)
摘要:题目:两个字符串,一个是普通字符串,另一个含有*和?通配符,*代表零个到多个任意字符,?代表一个任意字符,通配符可能多次出现。写一个算法,比较两个字符串是否相等。发现许多公司笔试面试都有这道题目,于是自己搜了一下,从redis源码util.c源文件中可以找到这么一个函数,实际上glib中也有类似的实现int stringmatch(const char *pattern, const char *string, int nocase) { return stringmatchlen(pattern,strlen(pattern),string,strlen(string),nocase)}st 阅读全文
posted @ 2013-10-18 19:48 godjob 阅读(5928) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <sqlite3.h>#include <stdlib.h>static sqlite3 *db=NULL;static sqlite3_stmt *stmt=NULL;FILE *fp;long filesize=0;char *fflie;int main(int argc, char *argv[]){ int rc,i,j; rc = sqlite3_open("dishes.db", &db); rc = sqlite3_prepare(db, "updat 阅读全文
posted @ 2012-11-25 20:58 godjob 阅读(1303) 评论(0) 推荐(0)
摘要:掌握文本文件读写的方法了解二进制文件的读写方法C++文件流:fstream // 文件流ifstream // 输入文件流ofstream // 输出文件流//创建一个文本文件并写入信息//同向屏幕上输出信息一样将信息输出至文件#include<iomanip.h>#include<fstream.h>void main(){ ofstream f1("d:\\me.txt"); //打开文件用于写,若文件不存在就创建它 if(!f1)return; //打开文件失败则结束运行 f1<<setw(20)<<"姓名:& 阅读全文
posted @ 2012-11-23 22:57 godjob 阅读(329) 评论(0) 推荐(0)
摘要:#include"stdafx.h"#include<iostream>#include<string>#include"http/request.h"usingnamespacestd;int_tmain(intargc,_TCHAR*argv[]){RequestmyRequest;//初始化类stringsHeaderSend;//定义http头stringsHeaderReceive;//返回头stringsMessage="";//返回页面内容boolIsPost=false;//是否Post提交in 阅读全文
posted @ 2012-10-09 23:46 godjob 阅读(870) 评论(0) 推荐(0)
摘要:源文章来自前C++标准委员会的Danny Kalev的The Biggest Changes in C++11 (and Why You Should Care),赖勇浩做了一个中文翻译在这里。所以,我就不翻译了,我在这里仅对文中提到的这些变化“追问为什么要引入这些变化”的一个探讨,只有知道为了什么,用在什么地方,我们才能真正学到这个知识。而以此你可以更深入地了解这些变化。所以,本文不是翻译。因为写得有些仓促,所以难免有问题,还请大家指正。Lambda 表达式Lambda表达式来源于函数式编程,说白就了就是在使用的地方定义函数,有的语言叫“闭包”,如果 lambda 函数没有传回值(例如voi 阅读全文
posted @ 2012-09-24 10:25 godjob 阅读(244) 评论(0) 推荐(0)
摘要:Java 运算符优先级运算符优先级postfixexpr++ expr--unary++expr --expr +expr -expr ~ !multiplicative* / %additive+ -shift<< >> >>>relational< > <= >= instanceofequality== !=bitwise AND&bitwise exclusive OR^bitwise inclusive OR|logical AND&&logical OR||ternary? :assignme 阅读全文
posted @ 2012-09-17 16:59 godjob 阅读(500) 评论(0) 推荐(0)