代码改变世界

随笔分类 -  C++

(转) 新的开始之Win7、CentOS 6.4 双系统 硬盘安装

2014-05-03 09:27 by hongjiumu, 177 阅读, 收藏,
摘要: http://blog.csdn.net/cnclenovo/article/details/11358447 阅读全文

WIN7下使用VC2010调试uCOS-II 2.91

2014-04-29 23:10 by hongjiumu, 1435 阅读, 收藏,
摘要: WIN7下使用VC2010调试uCOS-II 2.91http://www.amobbs.com/thread-5462878-1-1.htmlucos系统学习汇总http://www.cnblogs.com/gmh915/category/212499.html 阅读全文

Change ICON of MFC Application and Dialog

2014-04-29 22:53 by hongjiumu, 901 阅读, 收藏,
摘要: Change ICON of MFC Application and Dialoghttp://www.codeproject.com/Tips/406870/Change-ICON-of-MFC-Application-and-Dialog#include "FirstApp.h"#include... 阅读全文

VS2010下面Empty Project使用

2014-04-20 10:17 by hongjiumu, 655 阅读, 收藏,
摘要: VS2010下面Empty Project使用:1,添加代码HelloApp#include class CHelloApp:public CWinApp{public:virtual BOOL InitInstance();};CHelloApp HelloApp;class CHelloWind... 阅读全文

std::string compare

2014-03-08 17:45 by hongjiumu, 2014 阅读, 收藏,
摘要: #include #define NULL 0 #define MAX_LIMIT 5 //#define MAX_LENGTH 2 bool ComparePC2S(const char *,const std::string &); int main() { const std::string EXIT_STRING="exit"; std::cout<<"Over"<<std::endl; char * pChar(NULL); pChar=new char[MAX_LIMIT]; memset(pChar,' 阅读全文

读CRecordset

2014-03-08 17:44 by hongjiumu, 205 阅读, 收藏,
摘要: void CDictCol::LoadDictCol(void){// 加载数据字典信息CString cstrSql;cstrSql.Format("SELECT dc.TblID, dc.TblName, dc.ColName, dc.ColIndex ""FROM %s dc WHERE dc.TblID/10000 = %d ORDER BY TblName, ColIndex",DB_TABLE_CFG_DICT_COL.c_str(), E3GLOG_ENS_VERSION_ID);CRecordset* pRecords = m_pOdbc 阅读全文

SINGLETON

2014-03-08 17:43 by hongjiumu, 3 阅读, 收藏,
该文被密码保护。 阅读全文

CMoLineMgr

2014-03-08 17:41 by hongjiumu, 249 阅读, 收藏,
摘要: #ifndef __E3GLOGOBJECTDB_H__ #define __E3GLOGOBJECTDB_H__ #include "PubCommon\Singleton.h" #include "PubCommon\MemoryManager.h" #include "PubCommon.h" class CMoLineMgr { public: CMoLineMgr(Win32Tools::CMemoryManager* pMemMgr); virtual ~CMoLineMgr(); public: void AddMemL 阅读全文

c++多行字符串,可以这么写

2014-02-23 00:20 by hongjiumu, 7752 阅读, 收藏,
摘要: c++多行字符串,可以这么写:CString s;s.Format("CREATE TABLE %s(\[ID] [int] IDENTITY(1,1) NOT NULL,\[Vendor] [varchar](10) NULL,\[System] [varchar](4) NULL,\[FileType] [varchar](20) NULL,\[VersionID] [int] NULL,\[BSCNAME] [varchar](64) NULL,\[RNCID] [int] NULL,\[BSCFlg] [int] NULL,\[IsValid] [bit] NULL,\[Ve 阅读全文

CMoReader

2014-02-22 23:54 by hongjiumu, 254 阅读, 收藏,
摘要: #ifndef __E3GLOGLOADBYFILE_H__ #define __E3GLOGLOADBYFILE_H__ #include "PubCommon\MemoryManager.h" #include "PubCommon.h" //------------------------ // 读取内存中的 LOG 文件 //------------------------ class CMoReader { public: CMoReader(Win32Tools::CMemoryManager* pMemMgr); virtual ~CMoR 阅读全文

error C2556: 'const char &MyString::operator [](int)' : overloaded function differs only by return type from 'char &MyString::operator [](int)'

2014-02-15 20:40 by hongjiumu, 659 阅读, 收藏,
摘要: char & operator[](int i);const char & operator[](int i);/*const char & operator(int i);*/编译出错:error C2556: 'const char &MyString::operator [](int)' : overloaded function differs only by return type from 'char &MyString::operator [](int)'修改:char & operator[](in 阅读全文

error C2248: 'MyString::pCharArray' : cannot access private member declared in class 'MyString'

2014-02-15 20:38 by hongjiumu, 567 阅读, 收藏,
摘要: std::ostream & operator<<(std::ostream os,const MyString & mystr){os<<mystr.pCharArray;return os;};编译出错;error C2248: 'MyString::pCharArray' : cannot access private member declared in class 'MyString'修改:std::ostream & operator<<(std::ostream & os,cons 阅读全文

c++读文件

2014-01-18 21:34 by hongjiumu, 393 阅读, 收藏,
摘要: FileFormatDefine.h#ifndef _WIN32TOOLS_FILEFORMATDEFINE_H_ #define _WIN32TOOLS_FILEFORMATDEFINE_H_ const char FILE_END_CHAR = 26; #endif _WIN32TOOLS_FILEFORMATDEFINE_H_ FileReader.h#ifndef _WIN32TOOLS_FILEREADER_H_ #define _WIN32TOOLS_FILEREADER_H_ #include #include "FileFormatDefine.h" n.. 阅读全文

Run-Time Check Failure #0

2014-01-18 21:32 by hongjiumu, 2193 阅读, 收藏,
摘要: Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function pointer declared with a different calling convention.This debug error means that the stack pointer register is not returned to its original value after the funct 阅读全文

CString.Format %s 字符串 要用char *

2014-01-18 21:29 by hongjiumu, 735 阅读, 收藏,
摘要: CString.Format %s 字符串 错了,应该是:std::string str;CString sql;sql.Format("%s",str.c_str());所以正确的说法是%s c字符串 阅读全文

(转)DLL中导出函数的两种方式(dllexport与.def文件)

2014-01-18 21:28 by hongjiumu, 5864 阅读, 收藏,
摘要: DLL中导出函数的两种方式(dllexport与.def文件)http://www.cnblogs.com/enterBeijingThreetimes/archive/2010/08/04/1792099.htmlDLL中导出函数的声明有两种方式:一种方式是:在函数声明中加上__declspec(dllexport);另外一种方式是:采用模块定义(.def)文件声明,(.def)文件为链接器提供了有关被链接程序的导出、属性及其他方面的信息。方式一:在函数声明中加上__declspec(dllexport)/// 在动态链接库程序中/// 声明动态链接库(**.dll)的对外接口函数TestF 阅读全文

new placement 的使用

2014-01-18 21:27 by hongjiumu, 316 阅读, 收藏,
摘要: #include #include "TModel.h" int main() { char * p_char=new char[100]; std::coutShow(); delete pTModel; //The Second Part. TModel * pTModel2=(TModel *)(new char[sizeof(TModel)]); //If omitted, //at std::coutShow(); delete pTModel2; getchar(); ... 阅读全文

文件操作

2014-01-18 21:26 by hongjiumu, 217 阅读, 收藏,
摘要: 基于C的文件操作在ANSI C中,对文件的操作分两种方式:流式文件操作和I/O文件操作。一、流式文件操作这种方式的文件操作有一个重要的结构FILE,FILE在stdio.h中定义。FILE这个结构包含了文件操作的基本属性,对文件的操作都要通过这个结构的指针来进行。fopen的原型是:FILE *fopen(const char *filename,const char *mode),fopen实现三个功能:为使用而打开一个流 把一个文件和此流相连接 给此流返回一个FILR指针 参数filename指向要打开的文件名,mode表示打开状态的字符串,其取值如下表 字符串 含义 "r&qu 阅读全文

c++写文件

2014-01-18 21:25 by hongjiumu, 389 阅读, 收藏,
摘要: 写文件:#include #include #include int main() { FILE *fp; fp = _tfopen(_T("d:\\sss.ini"), _T("w")); //if (fp == NULL) //{ // fp=_tfopen(_T("d:\\sss.ini"), _T("w+b")); // // wchar_t m_strUnicode[1]; // m_strUnicode[0] = wchar_t(0XFEFF); // fputwc(*... 阅读全文

(转)探索C++的秘密之详解extern "C",这就是为什么很多.lib被我们正确调用确总是无法解析的。

2014-01-18 21:24 by hongjiumu, 498 阅读, 收藏,
摘要: (转载,绝对的有用)lib被我们正确调用确总是无法解析。这是C++编译和C编译的区别时常在cpp的代码之中看到这样的代码: #ifdef __cplusplus extern "C" { #endif //一段代码 #ifdef __cplusplus } #endif 这样的代码到底是什么意思呢?首先,__cplusplus是cpp中的自定义宏,那么定义了这个宏的话表示这是一段cpp的代码,也就是说,上面的代码的含义是:如果这是一段cpp的代码,那么加入extern "C"{和}处理其中的代码。 要明白为何使用extern "C", 阅读全文