Posted on 2007-08-06 01:09
谢迎飞 阅读(1074)
评论(5) 编辑 收藏 引用
前几天同事遇到一个小问题,他想编个小工具,主要用来在每个.cpp文件的开始加入一句公共的#include "",于是,感觉自己在C++这里好像也是个盲点,所以就帮忙一起想想,同时也有了一个想法就是可以借此系统的对C++和MFC,或者更多的类似问题和关于文件输入和输出的问题做个透彻的认识,同时也是想利用网络,来获得更多的事例和想法,或深刻的见解,请大家不吝赐教。
我先起个头第一期是关于CFile及其派生类
Use CFile and its derived classes for general-purpose disk I/O. Use ofstream or other Microsoft iostream classes for formatted text sent to a disk file.
It directly provides unbuffered, binary disk input/output services, and it indirectly supports text files and memory files through its derived classes.
Note that deleting the CFile object does not delete the physical file in the file system.
If you have not closed the file before destroying the object, the destructor closes it for you.
If you used new to allocate the CFile object on the heap, then you must delete it after closing the file. Close sets m_hFile to CFile::hFileNull.
So the member function Duplicate() should be use with Close() function, because of a new object which is created.
以上是个人在作例子和浏览msdn获得的一些结论,当然,除了单纯的针对本问题的关键是如何解决文件的随机读写,同时就是详细的文件输入和输出操作的结论,希望各位能够把自己遇到的关于文件输入输出操作的问题或解决方案共享出来,使我们每个人都能从中受益,同时享受技术带给我们的那份喜悦