資源簡介
一、實驗二:A Text Editor Imlementation(P242__243頁)
二、實驗的目的和要求:
1.采用C++的ASCII碼文件和串函數實現;
2.熟練掌握串運算的應用;
3.熟練掌握計算機系統的基本操作方法,了解如何編輯、編譯、鏈接和運行一個C++程序;
4.上機調試程序,掌握查錯、排錯使程序能正確運行。
代碼片段和文件信息
#include?“Utility.h“
#include?“dbl_lk_list.h“
#include?“String.h“
#include?“Editor.h“
void?main(int?argc?char?*argv[]) //?命令行參數
//?前提條件:?在命令行中給出輸入文件和輸出文件
//?操作結果:?讀輸入文件各行到文本緩存中,執行簡單的行編輯并寫文本緩存到輸出文件中
{
char?infName[256]outfName[256];
if?(argc?2)?
{ //?argc?2表無輸入文件名
cout?<“請輸入文件名(缺省:?file_in.txt):“;
strcpy(infName?read_in(cin).c_str());
if?(strlen(infName)?==?0)
{ //?infName為空
strcpy(infName?“file_in.txt“);
}
}
else
{ //?將argv[1]復制給infName
strcpy(infName?argv[1]);
}
ifstream?file_in(infName);???//?定義并打開輸入文件流
if?(file_in?==?0)?{
cout?<“打開輸入文件“?< exit(1);
}
if?(argc?3)?
{ //?argc?3表無輸出文件名
cout?<“請輸出文件名(缺省:?file_out.txt):“;
strcpy(outfName?read_in(cin).c_str());
if?(strl
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????7713??2006-10-08?05:48??Editor\dbl_lk_list.h
?????文件?????581715??2007-09-13?13:53??Editor\Debug\Editor.exe
?????文件?????837300??2000-01-07?06:29??Editor\Debug\Editor.ilk
?????文件?????441633??2000-01-07?06:29??Editor\Debug\Editor.obj
?????文件????2583516??2000-01-07?06:29??Editor\Debug\Editor.pch
?????文件????1180672??2000-01-07?06:29??Editor\Debug\Editor.pdb
?????文件??????99328??2000-01-07?06:29??Editor\Debug\vc60.idb
?????文件?????135168??2000-01-07?06:29??Editor\Debug\vc60.pdb
?????文件???????1381??2000-01-07?06:27??Editor\Editor.cpp
?????文件???????4528??2000-01-07?00:12??Editor\Editor.dsp
?????文件????????537??2004-05-22?11:13??Editor\Editor.dsw
?????文件?????581715??2007-09-13?13:53??Editor\Editor.exe
?????文件???????9471??2000-01-01?02:45??Editor\Editor.h
?????文件??????99328??2010-04-12?12:32??Editor\Editor.ncb
?????文件??????49664??2010-04-12?12:32??Editor\Editor.opt
?????文件???????1224??2000-01-07?06:29??Editor\Editor.plg
?????文件???????8218??2000-01-06?23:58??Editor\extend_dbl_lk_list.h
?????文件???????1215??2004-06-13?10:59??Editor\file_in.txt
?????文件??????????0??2000-01-07?06:30??Editor\file_out.txt
?????文件???????6529??2000-01-07?06:08??Editor\String.h
?????文件????????745??2000-01-06?21:04??Editor\Utility.h
?????目錄??????????0??2010-06-12?15:18??Editor\Debug
?????目錄??????????0??2010-06-12?15:17??Editor
-----------?---------??----------?-----??----
??????????????6631600????????????????????23
- 上一篇:MFC下使用TeeChart控件的
- 下一篇:C++.net推箱子游戲源代碼
評論
共有 條評論