C++ 读取二进制文件速度测试
摘要:一个二进制文件里有n 个数据,我想要随机读取K个 数据,并存储在内存中。void CDataToPyramid::CompareReadingSpeed(){ time_t rawtime; struct tm*timeinfo; time(&rawtime); timeinfo=localtime(&rawtime); char *nowtime=asctime(timeinfo); TCHAR Name[100]; MultiByteToWideChar(CP_ACP, 0, nowtime, -1, Name, 100); OutputDebugString(Name);
阅读全文
posted @
2013-07-30 16:23
markygis
阅读(1798)
推荐(0) 编辑
c++ 字符串数组
摘要:方法1int mm=10;string *a=new string[mm];for(int i=0;i<10;i++){ char temp[80];_snprintf(temp,79,"aa%d.dat",i);temp[79]=0; char *path=NULL;path=(char*)temp; a[i]=path;}for(int j=0;j<10;j++){ string bb=a[j]; const char * str=bb.c_str(); FILE *File=fopen(str,"rb+");}delete[] a;方法
阅读全文
posted @
2013-07-27 19:52
markygis
阅读(482)
推荐(0) 编辑
VC++ 在类中添加多线程操作
摘要:CTestThread.hpublic: CTestThread(void); ~CTestThread(void);public: void setvalue(); static DWORD _stdcall SecondThreadFunc(LPVOID lparam); //多线程测试,线程成员函数必须是静态变量,不知道为什么?第二种可以使全局函数CTestThread.cpp#include #include #include using namespace std;CTestThread::CTestThread(void){ tp.aa=14; tp.bb=124.789;}C..
阅读全文
posted @
2013-07-22 16:07
markygis
阅读(2369)
推荐(0) 编辑
vc++ 内存连续读写操作
摘要://初始化内存 int *data=(int*)malloc(sizeof(int)*4); ZeroMemory(data, sizeof(int)*4); int *m=(int*)malloc(sizeof(int)); ZeroMemory(m, sizeof(int)) ; *m=789; //*****将数据写入到内存 for(int i=0;i<2;i++) { *m=198+i; memcpy((int*)data+i,m,sizeof(int)); } //******内存数据读出,输出 static char buf1[30]; //...
阅读全文
posted @
2013-07-22 15:37
markygis
阅读(1345)
推荐(0) 编辑
c++ 字符串截取
摘要:string path="D:\\aa\\bb\\cc.txt"; string mainpath; string::size_type pos = path.find_last_of('\\');if( pos != string::npos ){ mainpath.assign( path, 0, pos + 1 );}
阅读全文
posted @
2013-07-17 11:14
markygis
阅读(607)
推荐(0) 编辑
C++ string 转 char*
摘要:string 转到 char* char name[20]; string sname=GatherName[n]; strcpy(name,sname.c_str());
阅读全文
posted @
2013-07-09 16:56
markygis
阅读(215)
推荐(0) 编辑
C 读写二进制文件
摘要:FILE *ffp; struct mystruct { int aa; int bb; }; struct head { float cc; float dd; }; if((ffp=fopen("D:\\aaa.dat","ab+"))!=NULL) { head myhead; myhead.cc=123.55; myhead.dd=789.11; fwrite(&myhead,sizeof(head),1,ffp); ...
阅读全文
posted @
2013-07-04 15:03
markygis
阅读(2441)
推荐(0) 编辑
C++ 里 构建动态二维数组
摘要://****动态二维数组 /* int m=3; int **data; int n=2; data=new int*[m]; for(int j=0;j<m;j++) { data[j]=new int[n]; } for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { data[i][j]=i+j; } } for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { TRACE(_T("%d"),data[i][j]); } } for(int i=0;i<m;i++
阅读全文
posted @
2013-07-03 08:46
markygis
阅读(276)
推荐(0) 编辑
生成不重复随机数,int转 TCHAR 打印输出
摘要:在0~n 中 随机去除不重复的k个数 int k=100; int n=80000; for(int i=0;k>0&&i<n;i++) { if((bigrand()%(n-i))<k) { TCHAR sz[20]; _stprintf(sz,_T("%d\n"),i); OutputDebugString(sz); k--; } }http://blog.csdn.net/hello_world_2012/article/details/8981723
阅读全文
posted @
2013-07-02 17:25
markygis
阅读(660)
推荐(0) 编辑