2011年4月23日
摘要: 那么到底如何查找文件呢?我们需要一个结构体和几个大家可能不太熟悉的函数。这些函数和结构体在<io.h>的头文件中,结构体为struct _finddata_t ,函数为_findfirst、_findnext和_fineclose。具体如何使用,我会慢慢讲来~ 首先讲这个结构体吧~ struct _finddata_t ,这个结构体是用来存储文件各种信息的。说实话,这个结构体的具体定义代码,我没有找到,不过还好,文档里面在_find里有比较详细的成员变量介绍。我基本上就把文档翻译过来讲吧: unsigned atrrib:文件属性的存储位置。它存储一个unsigned单元,用于表示 阅读全文
posted @ 2011-04-23 20:06 COS 阅读(1992) 评论(0) 推荐(0)
摘要: C++的static关键字 C++的static有两种用法:面向过程程序设计中的static和面向对象程序设计中的static。前者应用于普通变量和函数,不涉及类;后者主要说明static在类中的作用。一、面向过程设计中的static1、静态全局变量在全局变量前,加上关键字static,该变量就被定义成为一个静态全局变量。我们先举一个静态全局变量的例子,如下: //Example 1#include <iostream.h>void fn();static int n; //定义静态全局变量void main(){ n=20; cout<<n<<endl; 阅读全文
posted @ 2011-04-23 18:51 COS 阅读(370) 评论(0) 推荐(0)
摘要: 静态数据成员:下面看一个例子:#include <iostream.h>class Point{public:void output(){}static void init(){ } };void main( void ){Point pt;pt.init();pt.output(); }这样编译是不会有任何错误的。下面这样看#include <iostream.h>class Point{public:void output(){ }static void init(){ } };void main( void ){Point::output();}这样编译会处错,错 阅读全文
posted @ 2011-04-23 18:43 COS 阅读(643) 评论(0) 推荐(0)
摘要: assert 函数名:assert 功能:测试一个条件并可能使程序终止 用法:voidassert(inttest); 程序例: #include<assert.h> #include<stdio.h> #include<stdlib.h> structITEM{ intkey; intvalue; }; /*additemtolist,makesurelistisnotnull*/ voidadditem(structITEM*itemptr){ assert(itemptr!=NULL); /*additemtolist*/ } intmain(void 阅读全文
posted @ 2011-04-23 17:05 COS 阅读(3308) 评论(0) 推荐(1)