<?xml version="1.0" encoding="utf-8"?><rss version="2.0">
<channel>
<title><![CDATA[清钟沁桐]]></title>
<link>http://blog.pfan.cn/vfdff</link>
<description>编程爱好者博客</description>
<language>zh-cn</language>
			<item>
		<title><![CDATA[运输法虚重载]]></title>
		<link>http://blog.pfan.cn/vfdff/39220.html</link>
		<description><![CDATA[你这儿是没有办法把&lt;&lt;申明为virtual，因为作为成员函数&nbsp; &nbsp;&nbsp; &lt;&lt;只能是ostream的member。&nbsp; &nbsp;&nbsp; 不过换一种方法还是可以的&nbsp; &nbsp;&nbsp; 大致如下哈：&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; class&nbsp;&nbsp; FtpMessage&nbsp;&nbsp; {&nbsp; &nbsp;&nbsp; protected:&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; virtual&nbsp;&nbsp; void&nbsp;&nbsp; ToString(ostream&nbsp;&nbsp; &amp;os)&nbsp;&nbsp; =&nbsp;&nbsp; 0;&nbsp; &nbsp;&nbsp; public:&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; friend&nbsp;&nbsp; ostream&amp;&nbsp;&nbsp; operator&nbsp;&nbsp; &lt;&lt;(ostream&amp;&nbsp;&nbsp; os,&nbsp;&nbsp; FtpMessage&nbsp;&nbsp; &amp;&nbsp;&nbsp; msg);&nbsp; &nbsp;&nbsp; };&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ostream&amp;&nbsp;&nbsp; operator&nbsp;&nbsp; &lt;&lt;(ostream&amp;&nbsp;&nbsp; os,&nbsp;&nbsp; FtpMessage&nbsp;&nbsp; &amp;&nbsp;&nbsp; msg)&nbsp; &nbsp;&nbsp; {&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg.ToString(os);&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-11-03 21:47:00</pubDate>
		</item>
				<item>
		<title><![CDATA[select函数详解及应用]]></title>
		<link>http://blog.pfan.cn/vfdff/39183.html</link>
		<description><![CDATA[Select在Socket编程中还是比较重要的，可是对于初学Socket的人来说都不太爱用Select写程序，他们只是习惯写诸如connect、 accept、recv或recvfrom这样的阻塞程序（所谓阻塞方式block，顾名思义，就是进程或是线程执行到这些函数时必须等待某个事件的发生，如果事件没有发生，进程或线程就被阻塞，函数不能立即返回）。可是使用Select就可以完成非阻塞（所谓非阻塞方式non-block，就是进程或线程执行此函数时不必非要等待事件的发生，一旦执行肯定返回，以返回值的不同来反映函数的执行情况，如果事件发生则与阻塞方式相同，若事件没有发生则返回一个代码来告知事件未发生，而进程或线程继续执行，所以效率较高）方式工作的程序，它能够监视我们需要监视的文件描述符的变化情况——读写或是异常。下面详细介绍一下！Select的函数格式(我所说的是Unix系统下的伯克利socket编程，和windows下的有区别，一会儿说明)：int select(int maxfdp,fd_set *readfds,fd_set *writefds,fd_set *errorfds,struct timeval *timeout);先说明两个结构体：第一，struct fd_set可以理解为一个集合，这个集合中存放的是文件描述符(file descriptor)，即文件句柄，这可以是我们所说的普通意义的文件，当然Unix下任何设备、管道、FIFO等都是文件形式，全部包括在内，所以毫无疑问一个socket就是一个文件，socket句柄就是一个文件描述符。fd_set集合可以通过一些宏由人为来操作，比如清空集合 FD_ZERO(fd_set *)，将一个给定的文件描述符加入集合之中FD_SET(int ,fd_set *)，将一个给定的文件描述符从集合中删除FD_CLR(int ,fd_set*)，检查集合中指定的文件描述符是否可以读写FD_ISSET(int ,fd_set* )。一会儿举例说明。第二，struct timeval是一个大家常用的结构，用来代表时间值，有两个成员，一个是秒数，另一个是毫秒数。具体解释select的参数：int maxfdp是一个整数值，是指集合中所有文件描述符的范围，即所有文件描述符的最大值加1，不能错！在Windows中这个参数的值无所谓]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-10-31 21:26:00</pubDate>
		</item>
				<item>
		<title><![CDATA[利用结构体返回多个函数值]]></title>
		<link>http://blog.pfan.cn/vfdff/39080.html</link>
		<description><![CDATA[#include &lt;iostream.h&gt;#include &lt;malloc.h&gt;#include &lt;string.h&gt;typedef struct student {&nbsp;&nbsp; &nbsp;char name[10];&nbsp;&nbsp; &nbsp;int age;}Student;Student* fun1(){&nbsp;&nbsp;&nbsp; Student* ps = new Student;&nbsp;&nbsp;&nbsp; strcpy(ps-&gt;name, "zhong");&nbsp;&nbsp; &nbsp;ps-&gt;age&nbsp; = 0x100;&nbsp;&nbsp;&nbsp; return ps;}void main(){&nbsp;&nbsp;&nbsp; Student* ps=fun1(); &nbsp;&nbsp;&nbsp;&nbsp; cout&lt;&lt;"name:"&lt;&lt;ps-&gt;name&lt;&lt;"\t"&lt;&lt;"age:"&lt;&lt;hex&lt;&lt;(*ps).age&lt;&lt;endl;&nbsp;&nbsp;&nbsp; delete ps;}一般的函数只能由一个返回值如何同时返回 name 和age 呢？我们可以将其封装到一个结构体中，这样就可以通过结构体的方式同时返回这两个参数注意：每次使用了fun1后，一定要释放其内部声请的内存空间比如本程序中的 delete ps; ，否则将造成内存泄漏]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-10-24 23:53:00</pubDate>
		</item>
				<item>
		<title><![CDATA[DLL(动态链接库)专题]]></title>
		<link>http://blog.pfan.cn/vfdff/39008.html</link>
		<description><![CDATA[（0）&nbsp;&nbsp; Windows API中所有的函数都包含在dll中，其中有3个最重要的DLL。
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (1)&nbsp;&nbsp; Kernel32.dll
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 它包含那些用于管理内存、进程和线程的函数，例如CreateThread函数；
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (2)&nbsp;&nbsp; User32.dll
&nbsp;&nbsp;&nbsp;&nbsp; 它包含那些用于执行用户界面任务(如窗口的创建和消息的传送)的函数，例如CreateWindow函数；
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(3)&nbsp;&nbsp; GDI32.dll
&nbsp;&nbsp;&nbsp;&nbsp; 它包含那些用于画图和显示文本的函数。
&nbsp;
1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 静态库和动态库
(1)&nbsp;&nbsp; 静态库
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;函数和数据被编译进一个二进制文件(通常扩展名为.LIB)。在使用静态库的情况下，在编译链接可执行文件时，链接器从库中复制这些函数和数据并把它们和应用程序的其他模块组合起来创建最终的可执行文件(.Exe文件).当发布产品时，只需要发布这个可执行文件，并不需要发布被使用的静态库。
(2)&nbsp;&nbsp; 动态库
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在使用动态库的时候，往往提供两个文件：一个引入库(.lib)文件和一个DLL(.dll)文件。虽然引入库的后缀名也是”lib”，但是动态库的引入库文件和静态库文件有着本质上的区别，对一个DLL来说，其引入库文件(.lib)包含该DLL导出的函数和变量的符号名，而.dll文件包含该DLL实际的函数和数据。在使用动态库的情况下，在编译链接可执行文件时，只需要链接该DLL的引入库文件，该DLL中的函数代码和数据并不复制到可执行文件中，直到可执行程序运行时，才去加载所需的DLL，将该DLL映射]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-10-21 18:54:00</pubDate>
		</item>
				<item>
		<title><![CDATA[内存空间操作]]></title>
		<link>http://blog.pfan.cn/vfdff/38806.html</link>
		<description><![CDATA[一个new肯定只需要写一个delete：
int (*arr)[10] = new int[20][10];
//use it...
delete []arr;
或者：
int **arr2 = new int*[20];
for (int i = 0; i &lt; 20; ++i) arr2[i] = new int[10];
//use it...
for (int i = 0; i &lt; 20; ++i) delete arr2[i];
delete arr2;]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-10-10 17:53:00</pubDate>
		</item>
				<item>
		<title><![CDATA[函数可以独立使用的特例]]></title>
		<link>http://blog.pfan.cn/vfdff/38639.html</link>
		<description><![CDATA[如下代码：
const static LPCTSTR g_szIPCCustomMsg = &nbsp;&nbsp;&nbsp; _T("{34F673E2-878F-11D5-B98A-00B0D07B8C7C}");
const static UINT g_wmScanPassword =&nbsp;&nbsp;&nbsp; RegisterWindowMessage(g_szIPCCustomMsg);
函数在函数体外定义是合法的。

解释：
静态对象和全局对象的初始化是在main函数执行之前进行的. 初始化(包括构造, 析构)对象的时候可以调用函数, 并且也就这一种情况可以在主函数外部调用函数.
MFC里面不是有个全局变量theApp吗, 也是这样子.
另外，C语言只有规定过不能在函数体内定义函数，没有规定在函数体外不能调用函数，既然没有限制就是允许的！]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-10-01 20:14:00</pubDate>
		</item>
				<item>
		<title><![CDATA[介绍Windows的窗口、消息、子类化和超类化]]></title>
		<link>http://blog.pfan.cn/vfdff/38407.html</link>
		<description><![CDATA[眼见为实(2)：介绍Windows的窗口、消息、子类化和超类化
介绍Windows的窗口、消息、子类化和超类化
这篇文章本来只是想介绍一下子类化和超类化这两个比较“生僻”的名词。为了叙述的完整性而讨论了Windows的窗口和消息，也简要讨论了进程和线程。子类化（Subclassing）和超类化（Superclassing）是伴随Windows窗口机制而产生的两个复用代码的方法。不要把“子类化、超类化”与面向对象语言中的派生类、基类混淆起来。“子类化、超类化”中的“类”是指Windows的窗口类。
0 运行程序
希望读者在阅读本节前先看看"谈谈Windows程序中的字符编码"开头的第0节和附录0。第0节介绍了Windows系统的几个重要模块。附录0概述了Windows的启动过程，从上电到启动Explorer.exe。本节介绍的是运行程序时发生的事情。
0.1 程序的启动
当我们通过Explorer.exe运行一个程序时，Explorer.exe会调用CreateProcess函数请求系统为这个程序创建进程。当然，其它程序也可以调用CreateProcess函数创建进程。
系统在为进程分配内部资源，建立独立的地址空间后，会为进程创建一个主线程。我们可以把进程看作单位，把线程看作员工。进程拥有资源，但真正在 
CPU上运行和调度的是线程。系统以挂起状态创建主线程，即主线程创建好，不会立即运行，而是等待系统调度。系统向Win32子系统的管理员 
csrss.exe登记新创建的进程和线程。登记结束后，系统通知挂起的主线程可以运行，新程序才开始运行。
这时，在创建进程中CreateProcess函数返回；在被创建进程中，主线程在完成最后的初始化后进入程序的入口函数（Entry-point）。创建进程与被创建进程在各自的地址空间独立运行。这时，即使我们结束创建进程，也不会影响被创建进程。
0.2 程序的执行
可执行文件（PE文件）的文件头结构包含入口函数的地址。入口函数一般是Windows在运行时库中提供的，我们在编译时可以根据程序类型设定。在VC中编译、运行程序的小知识点讨论了Entry-point，读者可以参考。 

入口函数前的过程可以被看作程序的装载过程。在装载时，系统已经做过全局和静态变量（在编译时可以确定地址）的初始化，有初值的全局变量拥有]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-09-21 14:15:00</pubDate>
		</item>
				<item>
		<title><![CDATA[强制CPU开始新的周期的方法]]></title>
		<link>http://blog.pfan.cn/vfdff/38333.html</link>
		<description><![CDATA[#include &lt;afx.h&gt;#include &lt;stdio.h&gt;void GetCylc( unsigned int *lowPart, unsigned int *highPart ){&nbsp;&nbsp;&nbsp; __asm {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cpuid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 强制CPU开始新的周期&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;mov ecx, lowPart;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov ebx, highPart;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rdtsc&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;mov [ecx], eax;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov [ebx], edx;&nbsp;&nbsp;&nbsp; }}unsigned int lowPart1, lowPart2, highPart;int main(){&nbsp;&nbsp; &nbsp;char *s1 = "2o3i4jiojrewjeroiksopf";&nbsp;&nbsp; &nbsp;GetCylc( &amp;lowPart1, &amp;highPart );&nbsp;&nbsp; &nbsp;for(int i1=0;s1[i1]!=0;i1++) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;printf("%c",s1[i1]);&nbsp;&nbsp; &nbsp;printf("\n");&nbsp;&nbsp; &nbsp;CString s2 = "2o3i4jiojrewjeroiksopf";&nbsp;&nbsp; &nbsp;for(int i2=0;i2&lt;s2.GetLength();i2++) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-09-18 01:02:00</pubDate>
		</item>
				<item>
		<title><![CDATA[模式对话框]]></title>
		<link>http://blog.pfan.cn/vfdff/38324.html</link>
		<description><![CDATA[模式对话框
        作者：冯明德
       一、概述
        
        对话框是一种特殊的窗口，它依据对话框模板资源而建立。
        它与一般的窗口有些不同，很多过程由系统完成了，虽然用户还是要提供一个消息处理函数，但在此消息处理函数中，不需要将不关心的消息交由缺省消息处理函数。
        实际上，调用缺省处理的过程又系统完成。
        二、对话框消息处理函数
        
        对话框也需要用户提供一个消息处理函数，但这个处理函数没有普通窗口的消息处理函数"权利大"。
        对话框是一种系统定义的“窗口类”，它已经定义好了对应的消息处理函数。客户所作的消息处理函数，并不是直接与窗口连接，而是对对话框消息处理函数的一种补充，或者说“嵌入”。
        因此，对话框处理函数不需要调用“缺省消息处理函数”。
        当有消息被处理时，返回TRUE,没有消息需要处理时，返回FALSE，此时退出用户消息处理函数后，系统会去调缺省消息处理函数。
//对话框消息处理函数//返回值类型为BOOL,与普通窗口处理函数不同。BOOL CALLBACK AboutDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){     switch (message)     {     case WM_INITDIALOG :          return TRUE ;	//返回真，表示消息被处理了。               case WM_COMMAND :          switch (LOWORD (wParam))          {          case IDOK :          case IDCANCEL :               EndDialog (hDlg, 0) ;	//使用EndDialog关闭对话框               return TRUE ; //返回真，表示消息被处理了。          }          break ;     }     return FALSE ; ////返回假，表示消息未被用户处理,又缺省消息处理函数去处理。}]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-09-17 19:10:00</pubDate>
		</item>
				<item>
		<title><![CDATA[不同系统平台下的watcom设置方法]]></title>
		<link>http://blog.pfan.cn/vfdff/38173.html</link>
		<description><![CDATA[&nbsp;&nbsp;&nbsp; ●32位DOS平台配置&nbsp;&nbsp;&nbsp; WATCOM=C:\OpenWatcom&nbsp;&nbsp;&nbsp; PATH=C:\OpenWatcom\Binw&nbsp;&nbsp;&nbsp; INCLUDE=C:\OpenWatcom\H&nbsp;&nbsp;&nbsp; LIBPATH=C:\OpenWatcom\LIB386&nbsp;&nbsp;&nbsp; EDPATH=C:\OpenWatcom\EDDAT　&nbsp;&nbsp;&nbsp; ●32位Windows配置&nbsp;&nbsp;&nbsp; WATCOM=C:\OpenWatcom&nbsp;&nbsp;&nbsp; PATH=C:\OpenWatcom\Binnt&nbsp;&nbsp;&nbsp; INCLUDE=C:\OpenWatcom\H;C:\OpenWatcom\H\NT&nbsp;&nbsp;&nbsp; LIBPATH=C:\OpenWatcom\LIB386;C:\OpenWatcom\LIB386\NT&nbsp;&nbsp;&nbsp; EDPATH=C:\OpenWatcom\EDDAT]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-09-09 23:39:00</pubDate>
		</item>
				<item>
		<title><![CDATA[程序完全脱离BCB运行]]></title>
		<link>http://blog.pfan.cn/vfdff/38172.html</link>
		<description><![CDATA[1、在prject->Options->Compiler中点击Release
2、在prject->Options->Packages中去掉Builder with runtime packages选项
3、在prject->Options->Linker中去掉Use dynamic RTL 选项
4、然后再编译。
这样编译出来的程序才可以完全脱离BCB运行。]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-09-09 23:37:00</pubDate>
		</item>
				<item>
		<title><![CDATA[memcpy函数的正确调用方法]]></title>
		<link>http://blog.pfan.cn/vfdff/38079.html</link>
		<description><![CDATA[memcpy函数的正确调用方法memcpy函数的一般调用方法为"memcpy(dest,src,n);".其功能为把源串src中前n个字符拷贝到目的串dest中,因此目的串dest的最后长度应是n.当目的串为空或目的串原来的长度不大于n时,memcpy的结果是正确的,而当目的串原来的长度大于n时则调用memcpy函数后得到的结果是错误的,如例2所示.例2.编制memcpy函数演示程序#include&lt;stdio.h&gt;#include&lt;mem.h&gt;#include&lt;string.h&gt;void 
main(void){int i;static char dest［7］="First";static char 
src［］="Second";printf("\nTarget string 1 is 
:%s",dest);memcpy(dest,src,3);printf("\nTarget string 2 is 
:%s",dest);memcpy(dest,src,strlen(src));printf("\nTarget string 3 is 
:%s",dest);}本程序输出结果应为:Target string 1 is:FirstTarget string 2 
is:SecTarget string 3 is:Second但实际输出结果却是:Target string 1 
is:FirstTarget string 2 is:SecstTarget string 3 
is:Second显然,如此调用memcpy函数有时会得到错误的结果.若用如下语句代替"memcpy(dest,src,n);"语句,即可得到正确的结果.if(strlen(dest)&gt;n){for(i=0;dest［i］!='\0';i++)dest［i］=' 
';/*将dest赋空格*/dest［i］='\0';memcpy(dest,src,n);}else 
memcpy(dest,src,n);当然,也可自编一memcpy函数以代替库函数memcpy,由于篇幅所限,就不给出笔者自编的memcpy函数.与memcpy函数存在同样问题的函数还有memmove函数,经过上述方法处理后亦可获得正确结果.]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-09-04 12:33:00</pubDate>
		</item>
				<item>
		<title><![CDATA[C++中extern&nbsp;“C”含义深层探索]]></title>
		<link>http://blog.pfan.cn/vfdff/38069.html</link>
		<description><![CDATA[1.引言　　C++语言的创建初衷是“a better C”，但是这并不意味着C++中类似C语言的全局变量和函数所采用的编译和连接方式与C语言完全相同。作为一种欲与C兼容的语言，C++保留了一部分过程式语言的特点（被世人称为“不彻底地面向对象”），因而它可以定义不属于任何类的全局变量和函数。但是，C++毕竟是一种面向对象的程序设计语言，为了支持函数的重载，C++对全局函数的处理方式与C有明显的不同。　　2.从标准头文件说起　　某企业曾经给出如下的一道面试题：　　面试题　　为什么标准头文件都有类似以下的结构？ &nbsp;#ifndef __INCvxWorksh#define __INCvxWorksh #ifdef __cplusplusextern "C" {#endif /*...*/ #ifdef __cplusplus}#endif #endif /* __INCvxWorksh */　　分析　　显然，头文件中的编译宏“#ifndef __INCvxWorksh、#define __INCvxWorksh、#endif” 的作用是防止该头文件被重复引用。　　那么#ifdef __cplusplusextern "C" {#endif #ifdef __cplusplus}#endif 　　的作用又是什么呢？我们将在下文一一道来。&nbsp;　　3.深层揭密extern "C"　　extern "C" 包含双重含义，从字面上即可得到：首先，被它修饰的目标是“extern”的；其次，被它修饰的目标是“C”的。让我们来详细解读这两重含义。　　被extern "C"限定的函数或变量是extern类型的；　　extern是C/C++语言中表明函数和全局变量作用范围（可见性）的关键字，该关键字告诉编译器，其声明的函数和变量可以在本模块或其它模块中使用。记住，下列语句：　　extern int a;　　仅仅是一个变量的声明，其并不是在定义变量a，并未为a分配内存空间。变量a在所有模块中作为一种全局变量只能被定义一次，否则会出现连接错误。　　通常，在模块的头文件中对本模块提供给其它模块引用的函数和全局变量以关键字extern声明。例如，如果模块B欲引用该模块A中定义的全局变量和函数时只需包含模块A的头文件即可。这样，模块B中调用模块A中的函数时，在编译阶段，模块B虽然找不到]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-09-04 08:41:00</pubDate>
		</item>
				<item>
		<title><![CDATA[VC中检测内存泄露的代码]]></title>
		<link>http://blog.pfan.cn/vfdff/37986.html</link>
		<description><![CDATA[/*----------------------------------------------------------------VC中检测内存泄露的代码：在申请了动态内存空间后常常会忘记在不用的时候释放，这样会造成内存的浪费等其他问题。怎样检查你的代码有没有内存泄露呢? 需要在前面加上这些代码：#ifdef _DEBUG#define DEBUG_CLIENTBLOCK&nbsp;&nbsp; new( _CLIENT_BLOCK, __FILE__, __LINE__)#else#define DEBUG_CLIENTBLOCK#endif#define _CRTDBG_MAP_ALLOC#include &lt;stdlib.h&gt;#include &lt;crtdbg.h&gt;#include &lt;string.h&gt;#include &lt;stdio.h&gt;#ifdef _DEBUG#define new DEBUG_CLIENTBLOCK#endif然后在要检测的代码前面加上：_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );在后面加上：_CrtDumpMemoryLeaks();-------------------------------------------------------------------*/#ifdef _DEBUG#define DEBUG_CLIENTBLOCK&nbsp;&nbsp; new( _CLIENT_BLOCK, __FILE__, __LINE__)#else#define DEBUG_CLIENTBLOCK#endif#define _CRTDBG_MAP_ALLOC#include &lt;stdlib.h&gt;#include &lt;crtdbg.h&gt;#include &lt;string.h&gt;#include &lt;stdio.h&gt;#ifdef _DEBUG#define new DEBUG_CLIENTBLOCK#endifint main(){&nbsp;&nbsp;&nbsp; _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_L]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-08-31 16:26:00</pubDate>
		</item>
				<item>
		<title><![CDATA[ofstream&nbsp;对象的使用注意点]]></title>
		<link>http://blog.pfan.cn/vfdff/37983.html</link>
		<description><![CDATA[// VS6 2008/8/30#include &lt;iomanip&gt;#include &lt;fstream&gt;#include &lt;iostream&gt;using namespace std;struct data{&nbsp;&nbsp; &nbsp;unsigned type&nbsp;&nbsp; &nbsp;:&nbsp;&nbsp; &nbsp;2 ;&nbsp;&nbsp; &nbsp;unsigned d&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;:&nbsp;&nbsp; &nbsp;1 ;&nbsp;&nbsp; &nbsp;unsigned context:&nbsp;&nbsp; &nbsp;5 ;};// ofstream 对象不能复制，只能引用传参void fprint(ofstream &amp;file,struct data t){&nbsp;&nbsp; &nbsp;int temp = (t.type&lt;&lt;6) + (t.d&lt;&lt;5) + t.context;&nbsp;&nbsp; &nbsp;if (temp&lt;16)&nbsp;&nbsp; &nbsp;{&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;file&lt;&lt;hex&lt;&lt;0 ;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;file&lt;&lt;hex&lt;&lt;temp&lt;&lt;endl ;}int main(void){&nbsp;&nbsp;&nbsp; int j;&nbsp;&nbsp; &nbsp;ofstream fsOut("TestData.dat");&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for(j=0;j&lt;16;j++)&nbsp;&nbsp; &nbsp;{&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int j1=(j&amp;8)&amp;&amp;1,j2=(j&amp;4)&amp;&amp;1,j3=(j&amp;2)&amp;&amp;1,j4=j&amp;&amp;1;&nbsp;&nbs]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-08-31 09:12:00</pubDate>
		</item>
				<item>
		<title><![CDATA[测试程序效率的方法]]></title>
		<link>http://blog.pfan.cn/vfdff/37967.html</link>
		<description><![CDATA[http://1001night.blogbus.com/logs/17125497.html



光看书似乎不解决问题，难道要做题
    当然要做题，而且做题也要循序渐进。
    首先是教材正文中的示例，然后是书后的练习题。
    第二步可以做国家等级考试二级三级的C语言题。在线上可以找到，大量二级题库。三级题推荐南开的三级100题。此外VCgood群的共享文件中也有一些这一难度的题目。
    正如前面讲过，当第二步的题目都做完后，语法已经不是问题，应该开始学习数据结构和算法。这个方面的练习题可以去各大OJ。OJ是什么，请看下一节。


OJ是什么
    OJ是OnlineJudge的缩写。OnlineJudge是一种在线裁判系统。她可以对程序原代码进行编译和执行，并通过预先设计的测试数据来检验程序原代码的正确性。
    首先，他是一个在线的题库，有很多习题，你可以任选其中之一来解答。然后，系统的编译器能够编译执行你所提交的代码。如果编译通过，针对每个题目，系统将使用自带的多组测试数据检验你的程序，如果程序都能得到正确的输出，那么你顺利地解决了这个问题。最后，系统还能对所有参与答题的用户进行统计和排名。
    OJ的题目大部分是关于算法的。题目的输入输出通常是命令行方式，而非图形界面。也就是说，要关注的不是平台的兼容性、文件的格式抑或窗口的布置这种无关紧要的细节，而是问题本身的逻辑实现。一个用户提交的程序在Online Judge系统下执行时将受到比较严格的限制，包括运行时间限制，内存使用限制和安全限制等。用户程序执行的结果将被Online Judge系统捕捉并保存，然后再转交给一个裁判程序。该裁判程序或者比较用户程序的输出数据和标准输出样例的差别，或者检验用户程序的输出数据是否满足一定的逻辑条件。最后系统返回给用户一个状态，通过、错误、超时、溢出或是无法编译。
    Online Judge系统来自ACM和IOI大赛。由美国计算机协会（ACM Association for Computing Machinery）发起和组织的ACM国际大学生程序设计竞赛（简称ACM/ICPC）是目前世界上规模最大的计算机学科赛事。IOI则是国际信息学奥林匹克竞赛，和数学奥林匹克竞赛一样著名。Online Judge系统是IOI或A]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-08-30 15:00:00</pubDate>
		</item>
				<item>
		<title><![CDATA[c++格式化输入输出]]></title>
		<link>http://blog.pfan.cn/vfdff/37841.html</link>
		<description><![CDATA[cin与cout
一：标准输入函数cin
    不知道说它是个函数对还是不对，它是代表标准的输入设备--键盘。他是属于流的，他的用法和流的用法是一样的。也就是：cin>>变量;
小小的说明一下，输入多个变量可以写在一行，如:cin>>x>>y>>z;
这样写不是不允许，而是不好看，如果是不同的变量类型，那就更是没头没脑了。除了你，人家是不知道该输入什么的，所以，一般在输入语句的前面，我们一般都
要做一个提示，请输入×××，让人家心里有个底，知道这个变量是做什么的。
    另外，这个函数是不用带地址符号"&"的，也不用写明变量类型，千万不要跟scanf混淆。当然他就也不检查变量输入是否合法。如：

int i;
couti;
cout]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-08-24 22:40:00</pubDate>
		</item>
				<item>
		<title><![CDATA[矩阵求逆的算法]]></title>
		<link>http://blog.pfan.cn/vfdff/37795.html</link>
		<description><![CDATA[用C写的，做成DLL使用很方便。
    double * MatrixOpp(double A[],int m,int n) /*矩阵求逆*/
    {
     int i,j,x,y,k;
     double *SP=NULL,*AB=NULL,*B=NULL,X,*C;
     SP=(double *)malloc(m*n*sizeof(double));
     AB=(double *)malloc(m*n*sizeof(double));
     B=(double *)malloc(m*n*sizeof(double));
    
     X=Surplus(A,m,n);
     X=1/X;
    
     for(i=0;i]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-08-22 18:48:00</pubDate>
		</item>
				<item>
		<title><![CDATA[watcom编译器的环境变量设置]]></title>
		<link>http://blog.pfan.cn/vfdff/37714.html</link>
		<description><![CDATA[环境变量的设置具有优先级，也就是相同环境变量名下的多个变量值之间的关系是前面的变量具有优先级。而watcom对于环境变量比较敏感，需要优先设置。比如对一个程序编译的时候：
wcl386 -zq -bd -bt=os2 -l=os2v2_dll -I%WATCOM%\h\os2 hello.c -"option implib"
wcl386 -zq -bt=os2 -l=os2v2 main.c hello.lib
经常提示的错误：
 WATCOM C/C++32 Compile and Link Utility Version 10.0
    Copyright by WATCOM International Corp. 1988, 1994. All rights reserved.
    WATCOM is a trademark of WATCOM International Corp.
           wcc386 TEST.C
    WATCOM C32 Optimizing Compiler  Version 10.0a
    Copyright by WATCOM International Corp. 1984, 1994. All rights reserved.
    WATCOM is a trademark of WATCOM International Corp.
    C:\VC98\INCLUDE\stdio.h(23): Error! E1091: ERROR: Only Mac or Win32 
    看到了吧，这是由于默认采用了VC进行了编译，解决方法：
You have installed or are using Visual C++.  (Installing other compilers may
cause similar problems.)  WATCOM can still be used when other compilers are
installed, however the environment variables INCLUDE, LIB, and WATCOM need
to be set to the default values s]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-08-20 09:30:00</pubDate>
		</item>
				<item>
		<title><![CDATA[C和C++在函数声明中的区别]]></title>
		<link>http://blog.pfan.cn/vfdff/37581.html</link>
		<description><![CDATA[C语言标准中，对没有声明的函数默认为int类型返回，比如下面的代码，注释部分可省略：
#include 

// int max(int x,int y);

int main( )
{
    int a,b,c;
    scanf("%d,%d",&a,&b);
    c=max(a,b);
    printf("max=%d",c);
    return 0;
}

int max(int x,int y)
{
    int z;
    if(x>y)z=x;
    else z=y;
    return(z);
}
而ANSI C++更严格些，要求在函数调用前必须对所调用的函数做函数原型声明，上面的注释部分加上则会产生错误
而VC编译器本身能根据文件的后缀名来识别应该采用的是ANSI C(.c)或者ANSI C++(.cpp)标准,因此上述代码使用的
文件名以.c后缀能正常通过编译，而.cpp后缀时则将出错]]></description>
		<author><![CDATA[vfdff]]></author>
		<pubDate>2008-08-14 09:34:00</pubDate>
		</item>
		</channel>
</rss>