【正文】
):用于刪除一個文件,如果刪除成功,將返回文件代號,否則刪除失敗:可能是不存在該文件Int OpenFile(char filename[80]):用于打開一個文件,如果打開成功,則返回文件代號,否則打開失敗,可能是不存在該文件Void CloseFile(filename[80]): 用于關(guān)閉一個文件Void WriteToFile(filename[80]):用于寫順序文件 基本文件內(nèi)容的輸入 以及文件緩沖區(qū)的管理:首先根據(jù)用戶輸入的文件名打開一個文件,如果存在該文件,則打開成功,開始寫入內(nèi)容,此時繼續(xù)接受用戶輸入的內(nèi)容,注意,輸入直到用戶鍵入回車鍵即表示輸入完畢,此時將輸入的內(nèi)容根據(jù)文件緩沖區(qū)管理規(guī)則將用戶輸入的內(nèi)容進(jìn)行存儲至指定文件名的文件中Void ReadFromFile(filename[80]):用于讀順序文件 基本文件內(nèi)容的輸出 以及文件緩沖區(qū)的管理:從指定的文件中讀取文件中的內(nèi)容,并輸出。因為對文件句柄以及寫,讀隨機文件的理解不是很清晰,故而沒有動手實踐完成。佛山科學(xué)技術(shù)學(xué)院課程設(shè)計用紙4但從理論上的角度上講,只要操作合理,那么本程序?qū)⒖梢詫崿F(xiàn)對應(yīng)的功能。要多了解庫函數(shù),可以閱讀相應(yīng)的幫助文件來獲得有用的信息。 實踐感受每次的課程設(shè)計都是對我們所學(xué)知識的一個深化,在實踐過程中能遇到許多的問題,遇到問題?分析問題?解決問題,這樣對知識的理解得到一個升華。本次的課程設(shè)計,其實從某種程度上來說,還是挺有難度的,因為,之前對于 C 語言的了解是通過其高級函數(shù)的,如文件的訪問中,正是通過其高級函數(shù)來訪問的。后來在于伙伴的討論下,知道了 C 高級實用設(shè)計這本書,從次書中受益匪淺,加上 80x86 匯編語言程序設(shè)計,更是增長了自己對于匯編的見識,從此更加肯定了匯編在底層操縱的作用!而且通過此次的課程設(shè)計,認(rèn)識了討論的重要性,我個人覺得編碼正是如此,如果遇到了一個人難以解決,那么最好是提出來與伙伴或者同學(xué)一同探討,這不但能直到別人的向想法,更能讓自己認(rèn)識自己的不足,更有甚者,能夠增長自己的見識!?。。?!佛山科學(xué)技術(shù)學(xué)院課程設(shè)計用紙9參考資料 《計算機操作系統(tǒng)教程》 (第 2 版)張堯?qū)W 史美林 編著 清華大學(xué)出版社 《操作系統(tǒng)實驗指導(dǎo)》任愛華 李鵬 劉方毅 清華大學(xué)出版社 《操作系統(tǒng)實驗教程——核心技術(shù)與編程實例》顧寶根 王立松 顧喜梅 科學(xué)出版社 《80x86 匯編語言程序設(shè)計》沈美明,溫冬嬋編著,清華大學(xué)出版社5,、 《C 高級實用程序設(shè)計》王世元 編著 清華大學(xué)出版社 《C 語言程序設(shè)計》譚浩強 編著 清華大學(xué)出版社附錄:源代碼在 環(huán)境includeincludeincludeincludeincludeinclude//The number of type of interruptdefine INTER 0x21//The size of filenamedefine Num 80//the number of charactersdefine CNum 9//Function Of Selectionint OperOfSel(){//clrscr()。printf(\n0 Exit \n1 Create a new file \n2 Delete a existing file )。printf(\n5 Input basic contents to existing file )。printf(\n7 To validate the file is open or not )。//printf(\n9 To validate the writting contents to file )。printf(\n\nFunction Of Selection\n)。printf(\nInput Your Selction: )。sel)。}//Create a new filevoid CreateFile(char filename[80]){union REGS inregs,outregs。//The function number of create file is 5B=0x5B。=FP_SEG(filename)。int86x(INTER,amp。outregs,amp。if(==2){printf(\nFail To Create New File\n)。}if(==80)佛山科學(xué)技術(shù)學(xué)院課程設(shè)計用紙11{printf(\nFail to create file: %s The file has benn existed\n,filename)。}printf(\nCreate New File:%s Successfully!The File39。printf(The FileCode is:%d\n,)。struct SREGS segregs。=FP_OFF(filename)。intdosx(amp。outregs,amp。int result = 。}//Open an existing fileint OpenFile(char filename[80]){union REGS inregs,outregs。int result。=FP_OFF(filename)。//Set the way to access file=2。inregs,amp。segregs)。/*if(2==){printf(\nFail To Open The File:%s May not exist\n,filename)。}*/result = 。}//Close The Existing Filevoid CloseFile(char filename[80]){union REGS inregs,outregs。佛山科學(xué)技術(shù)學(xué)院課程設(shè)計用紙13int result。//To Close The File : We Should Open The File Firstly。=FP_OFF(filename)。//Set the way to access file=2。inregs,amp。segregs)。/*if(2==){printf(\nFail To Open The File:%s May not exist\n,filename)。}*/result = 。printf(\nFail to close the file: %s It may not exist\n,filename)。FileCode = 。 = FileCode。inregs,amp。printf(\nClose File: %s Successfully! rel=%d \n,filename,rel)。struct SREGS segregs。int FileCode。=0x3D。=FP_SEG(filename)。int86x(INTER,amp。outregs,amp。result = 。佛山科學(xué)技術(shù)學(xué)院課程設(shè)計用紙15}else{//printf(\nOpen the file: %s Successfully! Now the file will be close\n,filename)。getchar()。/*gets(WriteContents)。//int CharNum=0,i=0。while(WriteContents[i]!=39。){//CharNum++。}*/int count=0。//printf(i=%d\n,i)。int sumChar=0。i=CNum1。//WriteContents[i] = 39。if(count==1)佛山科學(xué)技術(shù)學(xué)院課程設(shè)計用紙16{WriteContents[i]=temp。count=0。WriteContents[i])。\n39。break。\n39。//printf(Hello World\n)。FileCode = result。=FP_OFF(WriteContents)。=FP_SEG(WriteContents)。=i。//int86x(INTER,amp。outregs,amp。intdosx(amp。outregs,amp。//printf(Now The Ax=%d\n,)。//printf(Hello World\n)。count = count+1。sumChar += 。}//end for circle。for(int k=0。k++){TempContents[k] = WriteContents[k]。//printf(WriteContents=%s\n,WriteContents)。/*for(int j=0。j++){printf(%c,WriteContents[j])。*///printf(end for circle i=%d\n,i)。//printf(i=%d\n,i)。ji。}printf(\n)。=0x40。=FP_SEG(WriteContents)。=i。//int86x(INTER,amp。outregs,amp。intdosx(amp。outregs,amp。sumChar += 。//printf(Now The Ax=%d\n,)。佛山科學(xué)技術(shù)學(xué)院課程設(shè)計用紙19//printf(i=%d\n,i)。void ReadFromFile(char filename[80]){union REGS inregs,outregs。int result。=0x3D。=FP_SEG(filename)。intdosx(amp。outregs,amp。result = 。}else{//printf(\nNow I39。=result。佛山科學(xué)技術(shù)學(xué)院課程設(shè)計用紙20//printf(%d\n,)。=FP_SEG(ReadContents)。intdosx(amp。outregs,amp。printf(Real Number Of Read Characters in file:%s : %d\n,filename,)。printf(\nThe Contents Of File: %s Are Listed Below: \n,filename)。i。}printf(\n)。i1024。if(ReadContents[i]==39。){break。while(ReadContents[i]!=NULL){i++。*/佛山科學(xué)技術(shù)學(xué)院課程設(shè)計用紙21/*for(int j=0。j++){printf(%c,ReadContents[j])。*/}}//validate function one:open file:after create one file, you can validate the//file is exist or not!void ValidateOpenFile(char filename[80]){FILE *fp。if(!fp){printf(\nOpen file: %s Failly! fail to validate open file function\n,filename)。}else{printf(\nOpen file: %s Successfully! success to validate open file function\n,filename)。}//validate function two:read file :after writting contents to one file,you can佛山科學(xué)技術(shù)學(xué)院課程設(shè)計用紙22//validate the contents whether it has been written to it or not!!void ValidateReadFile(char filename[80]){FILE *fp。if(!fp){printf(\nCan not read contents from file:%s It may not exist\n,filename)。}else{int count=0。char ch。printf(%c,ch)。printf(\nThe total number of contents of the file: %s are: %d\n,filename,count)。}佛山科學(xué)技術(shù)學(xué)院課程設(shè)計用紙23//Main Functionint main(){clrscr()。char DeleteFileName[Num]。char CloseFileName[Num]。char ReadingFileName[Num]。char ValidateReadFileName[Num]。//printf(Your Selection Is:%d\n,sel)。switch(sel)