我的程序有什么问题?
#include<stdio.h>#include<stdlib.h>
#define SEEk_END 2
void main()
{
FILE *file1,*file2;
char ch,infile,outfile;
int block[1024];
int i,last,size;
printf("Enter the infile name:\n");
scanf("%s",infile);
printf("Enter the outfile name:\n");
scanf("%s",outfile);
if((file1=fopen("infile","rb"))==NULL)
{
printf("can not open infile.\n");
exit(1);
}
if((file2=fopen(outfile,"wb"))==NULL);
{
printf("can not open outfile\n");
exit(1);
}
fseek(file1,-1L,SEEK_END);
size=(ftell(file1)/1024);
last=ftell(file1)-size*1024;
for(i=0;i<size;i++)
{
fread(&block,1024,1,file1);
if(fwrite(&block,1024,1,file2);
}
for(i=0;i<last;i++)
{
fread(&block,1024,1,file1);
fwrite(&block,1024,1,file2);
}
fclose(file1);
fclose(file2);
}
要求是只能用fread fwrite
多谢各位了。