前幾天同事遇到一個小問題,他想編個小工具,主要用來在每個.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獲得的一些結論,當然,除了單純的針對本問題的關鍵是如何解決文件的隨機讀寫,同時就是詳細的文件輸入和輸出操作的結論,希望各位能夠把自己遇到的關于文件輸入輸出操作的問題或解決方案共享出來,使我們每個人都能從中受益,同時享受技術帶給我們的那份喜悅
剛看完蜘蛛俠3,還不錯,看到結尾兩個朋友冰釋前嫌,但還是犧牲了一位,可是在朋友的葬禮上一個幕后的獨白,挺有感觸,生平第一次有意識的去聽寫英文電影原聲,有些慚愧,請各位閱讀者別嫌棄哦,現在就獻上:
Whatever come with on our way, whatever bad we have rage inside, we always have choice.
My friend tell me that, and he chose to be the best himself.
It is the choice make us who we are, and we can always choose to do what is right.
不知道加上下面的翻譯是否會減去原文的意義呢,總之,還是希望或許某時能得到不同的感覺,影片上的翻譯是:
不管我們碰到什么事,不管我們內心有什么怒火,我們總是有選擇的。
這是我的朋友哈里教我的。他選擇做最好的他。
我們的選擇決定了我們是什么樣的人,我們永遠可以選擇去做正確的事。
C++, 在今天大家都在專注于.NET和J2EE的時候,我卻喜歡上了C++,是喜歡還是因為它更接近底層,我也不知道。自己總覺得是因為在自己喜歡的領域,它或許是最佳的選擇。但是,也聽過一些牛人說把一門語言學精通了,其他也可以觸類旁通。我相信。所以,現在不曾動搖過,在不想以前那樣,樣樣都學點。到最后,毫無功底。同時,也一直對這次經歷常抱感恩之心。雖然很多事不盡如人意,但卻給了我在技術道路上不斷前行的指引。