随笔分类 -  C/C++

摘要:NAME epoll - I/O event notification facilitySYNOPSIS #include <sys/epoll.h>DEscrīptION epoll is a variant of poll(2) that can be used either as Edge or Level Triggered interface and scales well to large numbers of watched fds. Three system calls are provided to set up and control an epoll set: 阅读全文
posted @ 2012-02-02 11:01 令狐葱★ 阅读(7927) 评论(1) 推荐(0)
摘要://C++ 中的可变参数使用#include <stdio.h>#include <stdarg.h>intOpenFileArray(FILE***array,char*mode,char*filename,...){ char*pName=NULL; intnrFiles=0; intarrayIndex=0; if(filename==NULL){ return0; } //在参数表中创建一个索引使用的typedef va_listlistIndex; //在参数表中初始化第一个参数索引的宏 va_start(listIndex,filename); do{ .. 阅读全文
posted @ 2007-01-14 16:14 令狐葱★ 阅读(846) 评论(0) 推荐(0)
摘要:#include <iostream.h>structA{ chara;longb;charc;longd;};structB{ chara;charc;longb;longd;};#pragma pack(push, 1)structC{ chara;longb;charc;longd;};#pragma pack(pop)structD{ char*a;char*b;};//使用比特域的结构structBitField{ unsigneda1:11; //long 1 unsigneda2:11; unsignedb1:10; unsigneda3:11; //long 2.. 阅读全文
posted @ 2007-01-13 14:56 令狐葱★ 阅读(525) 评论(0) 推荐(0)
摘要:在这本书的最后一章提到算法的陷阱的时候举了几个例子,记下两个。1. 循环计数的覆盖如果把1加到数值为255的字节上,该字节就会变为0。unsignedchari;for(i=0;i<256;i++){ cout<<"test"<<(int)i<<endl;}这就会出现一个死循环了,因为255之后再加一就又为0了。2. 数组和继承的混用#include <iostream.h>classAverageJoe{public: longid;};classJetSet:publicAverageJoe{public: long 阅读全文
posted @ 2007-01-12 20:29 令狐葱★ 阅读(340) 评论(0) 推荐(0)
摘要:在VC++ 6.0 中使用_beginthread 和 _endthread 的时候,出现如下错误:error C2065: '_beginthread' : undeclared identifiererror C2065: '_endthread' : undeclared identifier解决方案:debug状态:settings->C/C++->Project Options中加入/MDdrelease状态:settings->C/C++->Project Options中加入/MD如果还不行,可以修改以下选项:project 阅读全文
posted @ 2007-01-12 11:26 令狐葱★ 阅读(1348) 评论(1) 推荐(0)