C语言高手进来教教我!一个文件读入一段文字

来源:百度知道 编辑:UC知道 时间:2024/06/19 15:27:39
就是我想用文件读入一段话,然后做编辑处理,怎么读呢?
如:
The importance of learning foreign language
One day
Small mouse: Mum, i am afraid, because i was almost caught by an old cat just now.
Mother Mouse: Baby, Do not worry, if i meet the old cat, you see what i shall do.
Then after an hour, old cat was coming the mouse' house. Mother mouse cried out:" wang, wang, wang"
And then the old cat left the mouse's home immediately.
Mother mouse told her baby: now you should know the importance of learning a foreign language.
Small Mouse nodded his head.
怎么读取啊??用C语言
只要能一行一行地读入就行啦

fgets

char *fgets(char *string, int n, FILE *stream);

fgets函数fgets函数用来从文件中读入字符串。fgets函数的调用形式如下:fgets(str,n,fp);此处,fp是文件指针;str是存放在字符串的起始地址;n是一个int类型变量。函数的功能是从fp所指文件中读入n-1个字符放入str为起始地址的空间内;如果在未读满n-1个字符之时,已读到一个换行符或一个EOF(文件结束标志),则结束本次读操作,读入的字符串中最后包含读到的换行符。因此,确切地说,调用fgets函数时,最多只能读入n-1个字符。读入结束后,系统将自动在最后加'\0',并以str作为函数值返回。

读取和写入都很简单。关键你说到了编辑,这个我还没用字符界面弄过。。
如果题目要求必须是字符界面的话,这个题目就有得编了。。。
否则的话窗口界面就很简单,因为有编辑框这个东西嘛。。。