前幾天同事遇到一個(gè)小問題,他想編個(gè)小工具,主要用來在每個(gè).cpp文件的開始加入一句公共的#include "",于是,感覺自己在C++這里好像也是個(gè)盲點(diǎn),所以就幫忙一起想想,同時(shí)也有了一個(gè)想法就是可以借此系統(tǒng)的對C++和MFC,或者更多的類似問題和關(guān)于文件輸入和輸出的問題做個(gè)透徹的認(rèn)識(shí),同時(shí)也是想利用網(wǎng)絡(luò),來獲得更多的事例和想法,或深刻的見解,請大家不吝賜教。
我先起個(gè)頭第一期是關(guān)于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.
以上是個(gè)人在作例子和瀏覽msdn獲得的一些結(jié)論,當(dāng)然,除了單純的針對本問題的關(guān)鍵是如何解決文件的隨機(jī)讀寫,同時(shí)就是詳細(xì)的文件輸入和輸出操作的結(jié)論,希望各位能夠把自己遇到的關(guān)于文件輸入輸出操作的問題或解決方案共享出來,使我們每個(gè)人都能從中受益,同時(shí)享受技術(shù)帶給我們的那份喜悅
剛看完蜘蛛俠3,還不錯(cuò),看到結(jié)尾兩個(gè)朋友冰釋前嫌,但還是犧牲了一位,可是在朋友的葬禮上一個(gè)幕后的獨(dú)白,挺有感觸,生平第一次有意識(shí)的去聽寫英文電影原聲,有些慚愧,請各位閱讀者別嫌棄哦,現(xiàn)在就獻(xiàn)上:
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.
不知道加上下面的翻譯是否會(huì)減去原文的意義呢,總之,還是希望或許某時(shí)能得到不同的感覺,影片上的翻譯是:
不管我們碰到什么事,不管我們內(nèi)心有什么怒火,我們總是有選擇的。
這是我的朋友哈里教我的。他選擇做最好的他。
我們的選擇決定了我們是什么樣的人,我們永遠(yuǎn)可以選擇去做正確的事。
C++, 在今天大家都在專注于.NET和J2EE的時(shí)候,我卻喜歡上了C++,是喜歡還是因?yàn)樗咏讓樱乙膊恢馈W约嚎傆X得是因?yàn)樵谧约合矚g的領(lǐng)域,它或許是最佳的選擇。但是,也聽過一些牛人說把一門語言學(xué)精通了,其他也可以觸類旁通。我相信。所以,現(xiàn)在不曾動(dòng)搖過,在不想以前那樣,樣樣都學(xué)點(diǎn)。到最后,毫無功底。同時(shí),也一直對這次經(jīng)歷常抱感恩之心。雖然很多事不盡如人意,但卻給了我在技術(shù)道路上不斷前行的指引。