【正文】
改的行,但如果要將行連同文檔中的上下文顯示,則需要另外單獨(dú)的命令。行編輯器只能從事最簡(jiǎn)單的輸入輸出。Text editor is the basic software tools, the use of puters for word processing, to achieve the insertion of text files, delete modify operation. Restrictions on these operating units to conduct the editor called line editing process. Line editor can be engaged in the input and output of the most simple. The input, editing, document display can not synchronously. Edit text files can be quite large, all read into memory is neither economic nor can always achieve. One solution is to edit line by line, any moment only put a line to edit the file in memory, known as the living area. Allow the discovery of the error input errors and corrected in time. In general, the user cannot enter text directly, but only through the brief mands in the text terminal, the document may be added or write. We use the string to define, design and realize a simple line editor, with the line editor row insert, delete and other basic functions.Keywords: line editor。行編輯器只能從事最簡(jiǎn)單的輸入輸出。一般而言,用戶無(wú)法直接輸入文本,而只能在文本終端上通過(guò)簡(jiǎn)要的命令,對(duì)已有的文檔進(jìn)行添加或編寫。輸入、編輯、文檔顯示并不能同步地進(jìn)行。摘 要文本編輯程序是利用計(jì)算機(jī)進(jìn)行文字加工的基本軟件工具,實(shí)現(xiàn)對(duì)文本文件的插入、刪除等修改操作。編輯的文本文件可能很大,全部讀入內(nèi)存的做法既不經(jīng)濟(jì)也不總能實(shí)現(xiàn)?,F(xiàn)利用字符串來(lái)定義,設(shè)計(jì)并實(shí)現(xiàn)了一個(gè)簡(jiǎn)單行編輯程序,具備行編輯器的行插入,行刪除等基本功能。輸入、編輯、文檔顯示并不能同步地進(jìn)行。 text。輸入、編輯、文檔顯示并不能同步地進(jìn)行?,F(xiàn)在常見的編輯器,都是通過(guò)移動(dòng)光標(biāo),來(lái)選取要編輯的文本段落,與此不同的是,行編輯只能對(duì)“當(dāng)前行”進(jìn)行編輯。因此我們用字符串來(lái)定義,可以增強(qiáng)行編輯器的應(yīng)用,增強(qiáng)可讀性,加快人們的編輯文本的效率,從而推進(jìn)社會(huì)的發(fā)展。在程序設(shè)計(jì)中采用了字符串的方法實(shí)現(xiàn)對(duì)簡(jiǎn)單的行編輯器。限制這些操作以行為單位進(jìn)行的編輯程序稱為行編輯程序。試按這種方法實(shí)現(xiàn)一個(gè)簡(jiǎn)單的行編輯程序,設(shè)文件每行不超過(guò)320個(gè)字符,很少超過(guò)80個(gè)字符。逐頁(yè)地(每頁(yè)20行)顯示活區(qū)內(nèi)容,每顯示一頁(yè)之后由用戶決定是否繼續(xù)顯示以后各頁(yè)(如果存在)。行編輯器字符串顯示模塊字符串插入模塊字符串刪除模塊幫助信息模塊 存儲(chǔ)結(jié)構(gòu)的定義typedef struct text{ char string[80]。Status Createlist(textp amp。int display(textp amp。head)。功能:在顯示的活區(qū)插入一行內(nèi)容。功能:從輸入文件讀取內(nèi)容到活區(qū)。 棧是一種先進(jìn)后出的線性表,為了能按照原來(lái)的輸入順序輸出元素,我在程序中設(shè)計(jì)了兩個(gè)棧,第一個(gè)棧用來(lái)存儲(chǔ)輸入的字符,然后把第一個(gè)棧的元素出棧,并且把出棧的元素放入第二個(gè)棧中,這樣就實(shí)現(xiàn)了出棧是元素的順序和最開始輸入的順序是一致的了。S,char amp。通過(guò)函數(shù)PrintStack(SqStack amp。int del(textp head)。head)。 Status LoadFile(textp head,FILE *fp)。輸出要?jiǎng)h除的行 返回定義指針變量text *p1,*p2,*p3給min和max賦初值定義整型變量min,max,i通過(guò)指針變量p1,找到min行在活區(qū)中的位置通過(guò)指針變量p1找到max行在活區(qū)中的位置刪除行min到max的內(nèi)容保存顯示刪除后的內(nèi)容saveanddisplay() 開 始函數(shù)實(shí)現(xiàn):執(zhí)行行刪