資源簡介
對讀入的某個文本文件input.txt中,拆出英文單詞,輸出一個按字典順序排列的單詞表,結果輸出在文本文件output.txt中,每個單詞一行,并在單詞后輸出該單詞出現的個數,兩個字段之間用逗號分隔。約定單詞僅由英文字母組成,單詞間由非英文字母分隔,相同單詞只輸出一個,大小寫不區分。

代碼片段和文件信息
/*?
?*?Copyright(C)?2014?Ruijie?Network.?All?rights?reserved.?
?*/
/*
?*?main.c?
?*?Original?Author:??wuyuanxia@ruijie.com.cn?2014-7-30?
?*
?*?To?extract?words?from?the?input?file?input.txt?and?output?words?in?alphabetical?order?to?
?*?output.txt?and?record?the?number?that?each?word?occured.The?program?assumes?that?a?word?length
?*?no?more?than?20.
?*/
#include?
#include?
#include?
#include?
#include?“word.h“
int?main?(int?argc?char?**argv)
{
????FILE?*fp_in;
????FILE?*fp_out;
????list_head_t?*head;??/*?The?head?of?word?list?*/
????
????fp_in?=?fopen(“input.txt“?“r“);
????if?(fp_in?==?NULL)?{
????????(void)printf(“Failed?to?open?input?file!\n“);
????????exit(1);
????}
????head?=?word_creat_list();
????head?=?word_fill_list(fp_in?head);
????fclose(fp_in);
????fp_out?=?fopen(“output.txt““w+“);
????if?(fp_out?==?NULL)?{
????????(void)printf(“Failed?to?open?output?file!\n“);
????????exit(1);
????}
????word_output_list(fp_out?head);
????fclose(fp_out);
????word_free(head);
????return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????42??2014-07-30?15:01??單詞處理作業\input.txt
?????文件???????2640??2014-05-11?16:19??單詞處理作業\list.h
?????文件???????1051??2014-07-31?10:19??單詞處理作業\main.c
?????文件????????171??2014-07-30?14:46??單詞處理作業\makefile
?????文件?????????46??2014-07-30?20:02??單詞處理作業\output.txt
?????文件???????5253??2014-07-31?09:11??單詞處理作業\word.c
?????文件????????910??2014-07-31?09:27??單詞處理作業\word.h
?????文件??????69852??2014-07-31?11:35??單詞處理作業\單詞處理程序運行結果報告.docx
?????目錄??????????0??2014-07-31?11:40??單詞處理作業
-----------?---------??----------?-----??----
????????????????79965????????????????????9
- 上一篇:GalleryScreenshot
- 下一篇:opencv頭文件以茲互勉
評論
共有 條評論