随笔分类 -  c++

上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页
摘要:#include #include struct pos2d{ int x; int y;};using namespace std;int main(){ //boost::interprocess::shared_memory_object类是按照单个字节的方式读写共享内存,用... 阅读全文
posted @ 2014-05-27 21:17 zzyoucan 阅读(883) 评论(0) 推荐(0)
摘要:1 前言Libevent是一个轻量级的开源高性能网络库,使用者众多,研究者更甚,相关文章也不少。写这一系列文章的用意在于,一则分享心得;二则对libevent代码和设计思想做系统的、更深层次的分析,写出来,也可供后来者参考。附带一句:Libevent是用c语言编写的(MS大牛们都偏爱c语言哪),而且... 阅读全文
posted @ 2014-05-25 23:08 zzyoucan 阅读(929) 评论(0) 推荐(0)
摘要:client.cpp// App02.cpp : 定义控制台应用程序的入口点。//#include #include #include #include #include #include #include #ifndef WIN32#include # ifdef _XOPEN_SOURCE_EX... 阅读全文
posted @ 2014-05-25 23:06 zzyoucan 阅读(607) 评论(0) 推荐(0)
摘要:很多时候,除了响应事件之外,应用还希望做一定的数据缓冲。比如说,写入数据的时候,通常的运行模式是:l决定要向连接写入一些数据,把数据放入到缓冲区中l等待连接可以写入l写入尽量多的数据l记住写入了多少数据,如果还有更多数据要写入,等待连接再次可以写入这种缓冲IO模式很通用,libevent为此提供了一... 阅读全文
posted @ 2014-05-25 14:25 zzyoucan 阅读(522) 评论(0) 推荐(0)
摘要:这个plug组件不知到底是什么东西,不知何com组件什么区别#include #include #include "D:\HELL0\I_HELL0.h"using namespace std;int main(){ INIT_PLUG I_HELL0* tf = NEW(HELL0);... 阅读全文
posted @ 2014-05-24 01:06 zzyoucan 阅读(219) 评论(0) 推荐(0)
摘要:#include #include using namespace std;//使用宽字符,我猜是为了适应那些要使用宽字符的国家int main(){ auto path = Plug::GetCurrentPath();//返回std::wstring宽字符 std::wstring ... 阅读全文
posted @ 2014-05-23 23:30 zzyoucan 阅读(2280) 评论(0) 推荐(0)
摘要:·C语言相关 对应于char, C语言中也有宽字符内型wchar_t。wchar_t被定义为:typedef unsigned shortwchar_t;显然它是16位的。wchar_t类型的常字串应该这样写:L"hello"。因此可以这样定义一个宽字符指针wchar_t *pwc=L"hello... 阅读全文
posted @ 2014-05-23 23:07 zzyoucan 阅读(1554) 评论(0) 推荐(0)
摘要:NULL、0、nullptrC的NULL在C语言中,我们使用NULL表示空指针,也就是我们可以写如下代码: int *i = NULL;foo_t *f = NULL; 实际上在C语言中,NULL通常被定义为如下: #define NULL ((void *)0) 也就是说NULL实际上是一个voi... 阅读全文
posted @ 2014-05-23 22:24 zzyoucan 阅读(420) 评论(0) 推荐(0)
摘要:c++指针只能说博大精深,在用的时候感觉好晕1.指针类型转换/*在指针的强制类型转换:ptr1=(TYPE*)ptr2中,如果sizeof(ptr2的类型)大于sizeof(ptr1的类型),那么在使用指针ptr1来访问ptr2所指向的存储区时是安全的。如果sizeof(ptr2的类型)小于size... 阅读全文
posted @ 2014-05-17 00:45 zzyoucan 阅读(363) 评论(0) 推荐(0)
摘要:1.基础知识/*可以定义大小是0的数组,但不能引用,因为没有指向任何对象new string[10]调用类的默认构造函数new int[10]没有初始化,但new int[10]()会将数组初始化成0,返回第一个元素的首地址*/#include #include using namespace st... 阅读全文
posted @ 2014-05-16 22:28 zzyoucan 阅读(369) 评论(0) 推荐(0)
摘要:#include using namespace std;struct MyStruct{ int s;};int main(){ void* addr = new MyStruct;//缓冲区地址,大小为mysturct的大小 int * naddr = new (addr)in... 阅读全文
posted @ 2014-05-16 00:42 zzyoucan 阅读(229) 评论(0) 推荐(0)
摘要:1.sprintf,sprintf_ssprintf(char* buffer, const char* format, [argument]);vs下需要加上_CRT_SECURE_NO_WARNINGS#include using namespace std;int main(){ cha... 阅读全文
posted @ 2014-05-15 23:01 zzyoucan 阅读(195) 评论(0) 推荐(0)
摘要:std::vector > level_info_vec; i->load_level_info(level_info_vec); ActorLevelInfo levelInfo = {0}; levelInfo = level_info_vec[0][1]; //int userID = 10... 阅读全文
posted @ 2014-05-14 21:38 zzyoucan 阅读(307) 评论(0) 推荐(0)
摘要:UserInfo uinfo = {0}; uinfo.userID = 5555; strcpy(uinfo.userName, "UserHost5555"); strcpy(uinfo.userPwd, "123456"); i->addUser_(uinfo); ... 阅读全文
posted @ 2014-05-14 11:26 zzyoucan 阅读(171) 评论(0) 推荐(0)
摘要://doc_anonymous_mutex_shared_data.hpp#include struct shared_memory_log{ enum { NumItems = 100 }; enum { LineSize = 100 }; shared_memory_log()... 阅读全文
posted @ 2014-05-14 01:45 zzyoucan 阅读(1925) 评论(0) 推荐(0)
摘要:发送端:#include #include #include using namespace std;#include #include #include using namespace boost::interprocess;int num = 0;mapped_region *mp_r;void... 阅读全文
posted @ 2014-05-13 21:16 zzyoucan 阅读(628) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std;void funa(int arg1, string arg2){ cout fun; fun = std::bind(&funa, std::placeholders::_1, std::p... 阅读全文
posted @ 2014-05-11 22:10 zzyoucan 阅读(163) 评论(0) 推荐(0)
摘要:#include #include #include #include #include #include #include #include #include #include using namespace std;struct MyStruct{ string stru; int ... 阅读全文
posted @ 2014-05-11 18:41 zzyoucan 阅读(3123) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2014-05-11 14:02 zzyoucan 阅读(534) 评论(0) 推荐(0)
摘要:stringstream本身的复制构造函数是私有的,无法直接用,于是带来了一些复杂的问题网上,流传着几种办法,如streamA.str(streamB.str()),但这种办法,复制的仅仅是初始化时的string会在以下这种情况下暴露出问题: stringstream s1("123aaa")... 阅读全文
posted @ 2014-05-11 11:13 zzyoucan 阅读(289) 评论(0) 推荐(0)

上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页