![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
vc++
文章平均质量分 53
nujsuez
这个作者很懒,什么都没留下…
展开
-
c++ 对象的互斥访问
首先,需要定义Mutex类: class Mutex { public: Mutex() {InitializeCriticalSection(&m_cs);} virtual ~Mutex() {DeleteCriticalSection(&m_cs);}转载 2016-02-06 11:04:02 · 1375 阅读 · 0 评论 -
c++ 加密方案
http://www.weidai.com/转载 2014-07-28 14:52:45 · 667 阅读 · 0 评论 -
c++ public, protected ,private 继承的关系
#include using namespace std; class A{public: int pub_num;protected: int pro_num;private: int pri_num;};//public 继承方式class B:public A{public: void SetPub(int m_pub){ pub原创 2014-06-12 16:01:31 · 741 阅读 · 0 评论 -
海量数据面试题整理
转:http://blog.csdn.net/hexinuaa/article/details/6637385海量数据面试题整理1. 给定a、b两个文件,各存放50亿个url,每个url各占64字节,内存限制是4G,让你找出a、b文件共同的url?方案1:可以估计每个文件安的大小为50G×64=320G,远远大于内存限制的4G。所以不可能将其完全加载到内存中处理。考虑采取分而治之的方法转载 2014-06-12 16:45:26 · 598 阅读 · 0 评论 -
sem_init sem_post sem_wait
信号量的数据类型为结构sem_t,它本质上是一个长整型的数。函数sem_init()用来初始化一个信号量。它的原型为: extern int sem_init __P ((sem_t *__sem, int __pshared, unsigned int __value)); sem为指向信号量结构的一个指针;pshared不为0时此信号量在进程间共享,否则只能为当前进程的所有转载 2014-07-02 15:25:15 · 860 阅读 · 0 评论 -
c++ threadpool.cpp
//threadpool.cpp #include #include "threadpool.h" using namespace std; pthread_mutex_t ThreadPool::mutexSync = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t ThreadPoo转载 2014-06-30 15:20:08 · 2060 阅读 · 0 评论 -
stl 统计一栋楼里的信息
//h#pragma once#include #include #include using namespace std;typedef struct __strClient{ string strName; int iNum; bool bSex; int iCell;}strClient ,*pStrClient;class CTemplate{ publ原创 2014-06-10 18:24:16 · 979 阅读 · 0 评论 -
c++ threadpool.h
//threadpool.h#include#include#include#include usingnamespace std;转载 2014-06-30 15:12:28 · 2066 阅读 · 0 评论 -
c++ threadpoolmain.cpp
//threadpoolmain.cpp转载 2014-06-30 15:23:43 · 676 阅读 · 0 评论 -
linux 一个超简单的makefile
.PHONY:cleanXX=g++exe=dididididididididi 4 obj=main.o threadpool.o 5 $(exe):$(obj) 6 $(XX) -pthread -Wall -g -o $(exe) $(obj) 7 main.o:main.cpp threadpool.h 8 $(原创 2014-07-14 11:03:02 · 784 阅读 · 0 评论 -
c++ 构造string 类
// 头文件#pragma once#include using namespace std;class CSimString{ friend ostream &operator<<( ostream &, const CSimString & ); private: char* pBuf; int len;public: CSimString(void); CSimS原创 2014-06-25 15:43:22 · 773 阅读 · 0 评论 -
c++ 重写read 和 write
针对传输大文件时,缓冲区达到极限,而需要多次读写的情况,比如传输视频文件。重新read 和 writessize_t Readn(int fd, void* vptr, size_t n){ size_t left; ssize_t nread; char *ptr; ptr = vptr; nleft =n; while(nleft >0){ nre转载 2014-06-26 15:40:28 · 822 阅读 · 0 评论 -
c++ 编写动态链接库,要遵循以下指导意见
1. 所有的接口函数都应该是原创 2014-05-21 11:24:02 · 975 阅读 · 0 评论 -
c 查询整型中1 的个数
#include "stdafx.h"#include #include unsigned int cal(unsigned n){ unsigned c = 0; printf("%x\n",n); while (n>0) { c += n&1; n=n>>1; } return c;}转载 2014-07-28 14:27:15 · 697 阅读 · 0 评论 -
c 取N中最大的K个数
// max_k_number.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include #include using namespace std;void partition(int a[], int s,int t,int &k) {//devide the array into three parts转载 2014-07-28 14:16:37 · 1171 阅读 · 0 评论 -
next数组的求解思路
void makeNext(const char P[],int next[]){ int q,k;//q:模版字符串下标;k:最大前后缀长度 int m = strlen(P);//模版字符串长度 next[0] = 0;//模版字符串的第一个字符的最大前后缀长度为0 for (q = 1,k = 0; q < m; ++q)//for循环,从第二个字符开始,依转载 2015-05-07 11:54:42 · 699 阅读 · 0 评论 -
linux 调试多线程
原文:http://www.cnblogs.com/cy568searchx/archive/2013/10/28/3391790.html你的软件在某个时刻停止服务,CPU占用达到100%+,这种问题一个可能的原因是产生了死循环,假设程序某处存在潜在的死循环,并在某种条件下会引发,本文以一个示例来定位出现死循环的位置。当程序某处存在死循环,通常定位问题及缩小范围的方法是,在可疑的转载 2015-04-16 17:09:06 · 1051 阅读 · 0 评论 -
trim 函数c实现
1 #include 2 #include 3 #include 4 5 6 char* mytrim(char* sDes, const char* sSrc) 7 { 8 if(sSrc == NULL || sDes == NULL) 9 return NULL; 10 char* t原创 2015-04-13 18:43:54 · 893 阅读 · 0 评论 -
c 全局静态变量的实例解释其作用域
glo.h 文件#pragma oncestatic int glo;one.h 文件void getone();one.cpp 文件#include "stdafx.h"#include "glovar.h"#include "one.h"void getone(){ glo = 13; printf("one: glo is %d \n",glo);}two.原创 2015-02-27 18:53:38 · 1061 阅读 · 0 评论 -
linux 查看库依赖关系
直接使用ldd 命令即可,可以查看可执行程序,比如:root@forlinx:~# ldd /bin/mvlinux-gate.so.1 => (0x00c7b000)libselinux.so.1 => /lib/i386-linux-gnu/libselinux.so.1 (0x00136000)librt.so.1 => /lib/i386-linux-gnu/libr转载 2015-02-11 15:11:43 · 12833 阅读 · 0 评论 -
设计模式c++
http://www.cnblogs.com/wanggary/category/294620.html转载 2014-10-04 22:45:15 · 739 阅读 · 0 评论 -
c写的一个简单的计算器
#include #include int main(){ float a , b; char t; while(1) { int u = scanf("%f %c %f",&a,&t,&b); switch(t) { case '+': printf("%.3f%c%.3f=%.3f\n",a,t,b,a+b) ;fflush(stdin); brea原创 2014-10-10 13:57:14 · 1578 阅读 · 0 评论 -
一个线程池的 uml逻辑图
原创 2014-10-08 16:53:38 · 4930 阅读 · 0 评论 -
fread和read的区别
fread返回的是一个FILE结构指针而read返回的是一个int的文件号前者fopen/fread的实现是靠调用底层的open/read来实现的.fopen/fread是C标准的库函数,操作的对象是: file streamopen/read是和操作系统有关的系统调用。操作的对象是: “file descriptor”f是ANSI的C标准库。后面的转载 2014-09-29 18:34:45 · 3631 阅读 · 0 评论 -
sizeof 和 strlen 有趣的操作
两个数组:char a[]原创 2014-04-14 22:01:11 · 673 阅读 · 0 评论 -
vector push_back 是否调用构造函数
#include #include using namespace std;class A { public: A() { cout<<"A()"<<endl; } A(const A& a) // 增加拷贝构造函数 { cout << "copy A()" << endl; } ~A() { cout<<"~A()"转载 2014-09-27 23:27:32 · 3100 阅读 · 0 评论 -
在线编译器http://codepad.org/
链接地址: http://codepad.org/转载 2014-06-19 15:22:33 · 3034 阅读 · 0 评论 -
c++ 虚函数表内存
转自:http://blog.csdn.net/haoel转载 2014-04-28 21:07:32 · 753 阅读 · 0 评论 -
c++ 删除整形数组中重复的数字
int *RemoveDup(int arr[], int n){ int *tmp = NULL; int *arr_new = NULL; arr_new = (int *)malloc(n*sizeof(int)); tmp = arr_new; set s; pair::iterator, bool> p;// list l; 用list也可以保存 int k = 0;原创 2014-05-12 23:55:12 · 5821 阅读 · 0 评论 -
wmi 查找BIOS信息
1.初始化COMWMI提供的API是基于COM的,所以必须首先执行CoInitializeEx和 CoInitializeSecurity函数,以便访问WMI。 这里需要如下定义和头文件:#define_WIN32_DCOM#include #include#include#pragmacomment(lib,"wbemuuid.lib") #inc转载 2013-04-28 10:13:12 · 3193 阅读 · 0 评论 -
宏BUF_SIZE_BYTES(buf)和BUF_SIZE_CHARS(buf)计算数组最大容纳字节数和字符数
//calculate the number of bytes of the max size#define BUF_SIZE_BYTES(buf) (sizeof(buf)-sizeof(buf[0]))//calculate the number of characters of the max size#define BUF_SIZE_CHARS(buf) (sizeof(b原创 2013-04-09 15:31:00 · 2577 阅读 · 0 评论 -
TCHAR,CHAR 和WCHAR函数对比列表
ANSIWideTCHAR_access_waccess_taccess_atoi64_wtoi64_tstoi64_atoi64_wtoi64_ttoi64_cgets_cgetwscgetts_chdir_wchdir_tchdir_chmod_wchmod_tchm转载 2013-04-09 16:21:22 · 1568 阅读 · 0 评论 -
netcard
http://go.paowang.net/blog/sgt/archives/002196.htmlhttp://www.dewen.org/q/951http://bbs.znpc.net/forum.php?mod=viewthread&tid=558http://www.myexception.cn/c-builder/214106.htmlhttp://blog.csdn转载 2013-02-06 00:41:59 · 886 阅读 · 0 评论 -
虚函数不能为构造函数
个人认为主要原因有两个原因1. 虚函数是由一个Virtual Table(虚函数表)来实现,这个表中主要是虚函数的地址表; 这个 vtable 被分配在对象的内存中; 如果构造函数是虚函数,需要通过vtable来调用,可是对象还没有被实例化也就是还没有内存空间,无法找到vtable;原因2.原创 2013-01-06 23:54:13 · 601 阅读 · 0 评论 -
c++ DLL 简单接口实例
给用户提供接口的时候应该至少有以下几个文件:ISample.h 提供给用户的接口头文件,里面应该有接口函数的定义,一般都是纯虚函数。SampleAPI.h 提供给用户的接口头文件,里面应该有DLL应用程序的入口点,以及ISample 对象的创建和析构。CSample.h 不提供给用户,一般继承自ISample 并且实现ISample 里接口函数的功能。以下是一个简单的例子:/*原创 2012-12-20 19:48:30 · 3430 阅读 · 1 评论 -
c++ 字符串反转方法 UNICODE 和 ANSI 版本
#include "stdafx.h"#include #include #include #include #define chmalloc (TCHAR*)malloc(nCharacter*sizeof(TCHAR))static BOOL StringReverseW(PWSTR pWideCharStr,DWORD cchLength){ //Ge原创 2013-01-04 16:33:22 · 1380 阅读 · 0 评论 -
c++判断操作系统类型
判断操作系统类型1.是否是win9x//if os is windows 9x return true ,else return falsebool IsWinows9x( void ){ OSVERSIONINFO osVersion = {0}; osVersion.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); ::G原创 2012-12-10 16:25:12 · 2802 阅读 · 0 评论 -
_declspec(dllexport) 与__declspec(dllimport) 的使用说明
__declspec(XXXXXX)是windows扩展C++的编译宏头_declspec(dllexport) 声明一个导出函数,是说这个函数要从本DLL导出。我要给别人用。一般用于dll中 。省掉在DEF文件中手工定义导出哪些函数的一个方法。当然,如果你的DLL里全是C++的类的话,你无法在DEF里指定导出的函数,只能用__declspec(dllexport)导出类。转载 2012-11-12 15:17:43 · 1246 阅读 · 0 评论 -
关于strlen 和 wstlen_s 操作未初始化的字符数组
看下面一段程序#include "stdafx.h"#include #include #include int _tmain(int argc, _TCHAR* argv[]){ wchar_t aa[100],bb[200],cc[300]; int len = wcslen(aa); std::cout len = wcslen(bb); std原创 2012-06-15 17:33:47 · 974 阅读 · 0 评论 -
检测退出时的内存泄漏点
Detected memory leaks!Dumping objects ->{98500} normal block at 0x05785AD0, 152 bytes long. Data: 3C AC 4E 10 00 00 00 00 BC A4 4E 10 78 B6 37 00 Object dump complete. 而且每次退出都是一样的.泄漏的内存块都是98500.转载 2012-06-12 13:55:54 · 648 阅读 · 0 评论