
c/c++
嘻嘻宝贝
覃奋伴你返学海,伟业始于此举中。
展开
-
特殊数据类型成员变量的初始化
有些成员变量的数据类型比较特别,它们的初始化方式也和普通数据类型的成员变量有所不同。这些特殊的类型的成员变量包括:a. 常量型成员变量b. 引用型成员变量c. 静态成员变量d. 整型静态常量成员变量e. 非整型静态常量成员变量 对于常量型成员变量和引用型成员变量的初始化,必须通过构转载 2013-04-11 10:17:03 · 422 阅读 · 0 评论 -
C++文件读写
std::string strDir = std::string(szSetPath) + std::string("\\out.txt");ifstream ifs;ofstream ofs(strDir.c_str());vector csv_vec = statdir.BeginBrowseFilenames("*.*");static int csv = 0;for(vec原创 2015-10-29 10:54:31 · 394 阅读 · 0 评论 -
vector<string>转换为char*[]
int ReqSubMarketData(std::vector& vecInstrucment){ char** destination = new char*[vecInstrucment.size() + 1]; MakeCString(vecInstrucment, destination); // param char* ppD[], int nSize Subs原创 2015-10-29 12:01:12 · 6156 阅读 · 0 评论 -
将字符串的前八个字节转换为__int64位整数
__int64 CCtpKernel::ColumnStringToInt64(std::string& strName){ __int64 nRet = 0; const char* p = strName.c_str(); char* s = (char*)&nRet; for (int i = 0; i < 8 && *p != '\0'; i++) { *s = *p;原创 2015-10-29 10:58:49 · 1050 阅读 · 0 评论 -
COM:将不同数据类型打包为VARIANT
1、std::vector& vtDocs打包:CComBSTR bstrVal;CComSafeArray bstrArray;for (int i = 0; i != vtDocs.size(); i++){ bstrVal = vtDocs[i]; bstrArray.Add(bstrVal);}VARIANT varVal;V_VT(&varVal) = VT_B原创 2014-12-25 10:01:52 · 627 阅读 · 0 评论 -
Get the 48×48 or 256×256 icon of a file on Windows
转载自 http://pogopixels.com/blog/getting-the-48x48-or-256x256-icon-of-a-file-on-windows/转载 2014-09-16 10:43:05 · 806 阅读 · 0 评论 -
rapidxml读取包含中文路径的xml解析错误的解决方法
#ifdef _UNICODEsetlocale(LC_ALL, "Chinese-simplified");// 设置中文环境USES_CONVERSION;filesetlocale(LC_ALL, "C");// 还原#elsefile#endifxml_documentXmlAnalyse.parse(doc.data());原创 2014-08-27 09:30:26 · 2941 阅读 · 0 评论 -
Accelerated C++笔记
1、像所有的标准库长度类型一样,vector::size_type是无符号原创 2014-05-21 18:08:51 · 634 阅读 · 0 评论 -
UNICODE下调整字符串长度包含中英文(以字节为长度)
在编码过程中,由于字符串过长,我们需截取部分字符串,然后以省略号代替,但因为中文占两个字节长度,而英文占一个字节长度,而在UNICODE中,都是占据两个字节,但在界面显示效果中,一个中文占据了两个英文的长度,所以,我们需要重新计算下,而不是简单的用CString的Left函数进行截取。int num = 0; int numc = 0; int nume = 0; bool原创 2014-03-18 10:13:30 · 2033 阅读 · 0 评论 -
COM与Javascript交互
1、COM调用Javascript函数void CWebShareView::GoToPage(OLECHAR* pszFunct, UINT nCurSel){ HRESULT hr; LPDISPATCH pDisp = GetHtmlDocument(); IHTMLDocument2* phd=NULL; hr = pDisp->QueryInterfac转载 2014-03-17 14:56:43 · 1514 阅读 · 0 评论 -
常用代码片段集锦
1、遍历删除目录下文件void DeleteDirectory( LPCTSTR szDir ){ if( !szDir ) return; CString strDir; strDir.Format("%s\\*.*",szDir ); CFileFind filefind; BOOL bFind = filefind.FindFile( strDir ); w转载 2014-03-17 09:34:56 · 728 阅读 · 0 评论 -
vector<int> 转换为 int*
// libvtftp.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #include void ShowIntArray(int* p, int nSize){ if (NULL == p || nSize <= 0) { return; }转载 2014-02-17 11:39:06 · 8840 阅读 · 0 评论 -
c++ standard library note
书籍:《C++ 标准程序库》// http://www.gotw.ca/default.htm#1. Default Template Parameters (缺省模板参数)Template classes 可以有缺省参数。例如以下声明,允许你使用一个或两个template参数来声明MyClass对象:template >//注意,两个“>”之间必须有一个空格,如果你没写转载 2013-05-13 12:28:29 · 579 阅读 · 0 评论 -
格式化浮点数
void FormatDouble(double& dlf){ const double InvalidDouble = *(double*)("\xff\xff\xff\xff\xff\xff\xef\x7f"); const double ZeroDouble = *(double*)("\x00\x00\x00\x00\x00\x00\x00\x00"); dlf = (dlf ==原创 2015-10-29 10:56:02 · 888 阅读 · 0 评论