请改一c程序 急用!!!!一万个感谢!

来源:百度知道 编辑:UC知道 时间:2024/05/13 10:57:26
#include<stdio.h>
void copy(char s[],char t[])
{FILE *f1,*f2;
if((f1=fopen(s,"r"))==NULL)exit(0);
if((f2=fopen(t,"w"))==NULL)exit(0);
while(!feof(f1))fputc(fgetc(f1),f2);
fclose(f1);fclose(f2);
}
void list(char s[])
{FILE *f1;char ch;
if((f1=fopen(s,"w"))==NULL)exit(0);
while(!feof(f1)){ch=fgetc(f1);putchar(ch);}
fclose(f1);
}
void connect(char s[],char t[])
{FILE *f1,*f2;
if((f1=fopen(s,"a"))==NULL)exit(0);
if((f2=fopen(t,"r"))==NULL)exit(0);
while(!feof(f2)){fputc(fgetc(f2),f1);}
fclose(f1);fclose(f2);
}
void compare(char s[],char t[])
{FILE *f1,*f2; int n;
if((f1=fopen(s,"r"))==NULL)exit(0);
if((f2=fopen(t,"r"))==NULL)exit(0);
while(!feof(f1)){if(fgetc(f1)==fgetc(f2))n=1;else {n=0;break;}}
if(n)puts("YES");else puts("NO");
fclose(f1);fclose(f2);
}

///////////////////////////////////////////////////////////
替你把错误改了,现在可以运行。
至于那些函数到底做什么我不能确定功能,所以没有帮你修改实现。
#include<stdio.h>
#include<stdlib.h>

void copy(char s[],char t[])
{
FILE *f1,*f2;

if((f1=fopen(s,"r"))==NULL)
exit(0);

if((f2=fopen(t,"w"))==NULL)
exit(0);

while(!feof(f1))fputc(fgetc(f1),f2);
fclose(f1);fclose(f2);
}

void list(char s[])
{
FILE *f1;char ch;

if((f1=fopen(s,"w"))==NULL)
exit(0);

while(!feof(f1))
{
ch=fgetc(f1);
putchar(ch);
}
fclose(f1);
}

void connect(char s[],char t[])
{
FILE *f1,*f2;

if((f1=fopen(s,"a"))==NULL)
exit(0);

if((f2=fopen(t,"r"))==NULL)
exit(0);

while(!feof(f2))
{
fputc(fgetc(f2),f1);
}