level 11
醉忆曲终人壹
楼主
25、分析下列程序的功效
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
int main(int argc,char*argv[])
{
if(argc<3)
printf("命令语法不正确。\n");
FILE* fp=fopen(argv[1],"r");
if(fp)
{
fseek(fp,0,SEEK_END);
int n=ftell(fp);
printf("%d\n",n);
char* buff=(char*)malloc(n); ;
FILE*fp2=fopen(argv[2],"w");
fseek(fp,-n,SEEK_CUR);
printf("%d\n",fread(buff,1,n,fp));
fclose(fp);
fwrite(buff,1,n,fp2);
fclose(fp2);
free(buff);
}
}
2015年07月23日 15点07分
1
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
int main(int argc,char*argv[])
{
if(argc<3)
printf("命令语法不正确。\n");
FILE* fp=fopen(argv[1],"r");
if(fp)
{
fseek(fp,0,SEEK_END);
int n=ftell(fp);
printf("%d\n",n);
char* buff=(char*)malloc(n); ;
FILE*fp2=fopen(argv[2],"w");
fseek(fp,-n,SEEK_CUR);
printf("%d\n",fread(buff,1,n,fp));
fclose(fp);
fwrite(buff,1,n,fp2);
fclose(fp2);
free(buff);
}
}