C语言文件类题

来源:百度知道 编辑:UC知道 时间:2024/05/27 12:04:18
题:在temp文件夹下的英文文档my.txt,进行如下的操作,试写C程序。
1.在屏幕上原样输出该文件内容。
2.统计文档字符的个数。
3.统计文档共有多少行。
4.输出文档中最长的那一行。
5.将文档各行按行长度降序排列后输出到屏幕和文件my1.txt中。
6.统计各行单词的个数。
7.将文档内容按奇数行字符升序排列、按偶数行字符降序排列后,输出到屏幕的文件my2.txt中。
8.将文档各单词首字母变为相应的大写字母,输出到屏幕和文件my3.txt中。
9.删除文档中所以的空格,输出到屏幕和文件my4.txt中。
10.复制一份该文件,文件名为my5.txt。
要求:每小题用一个自定义函数完成,新生成的文件均放回原处。

有注释的加分!
简单易懂的来

文本my.txt
内容:
People travel for a lot of reasons.
Some tourists go to see battlefieldsor religious shrines.
Others are looking for culture, or simply want to have their pictures taken
in front of famous places. But most European tourists arelookingfor a sunny
beach to lie on.

#include<stdio.h>
#include<string.h>
#define size 10000

void readFile(FILE *pFile,char *name)
{
char ch[size];
memset(ch,0,size);
pFile=fopen(name,"r");
fread(ch,1,size,pFile);
fclose(pFile);
puts(ch);
}

int charFile(FILE *pFile,char *name)
{
int count=0;
int flag=size;
pFile=fopen(name,"r");
fseek(pFile,0,SEEK_END);
count=ftell(pFile);
fclose(pFile);
return count;
}

int lineFile(FILE *pFile,char *name)
{
int line=0;
char ch;
pFile=fopen(name,"r");
while(!f