#include <myhead.h>
int main(int argc, const char *argv[])
{
FILE *fp=fopen("./4.txt","r");
if(fp==NULL)
{
perror("fp");
return -1;
}
char a[100];
int n=0;
while(NULL!=fgets(a,sizeof(a),fp))
{
n++;
fputs(a,stdout);
}
fclose(fp);
printf("%d\n",n);
return 0;
}
#include <myhead.h>
int main(int argc, const char *argv[])
{
if(argc!=3)
{
printf("外部参数错误\n");
return -1;
}
FILE *fp1=fopen("./3.txt","r");
if(fp1==NULL)
{
perror("fp1");//输出错误信息
return -1;
}
FILE *fp2=fopen("./2.txt","w");
if(fp2==NULL)
{
perror("fp2");
return -1;
}
char a[100];
while(fgets(a,sizeof(a),fp1)!=NULL);
{
fputs(a,fp2);
}
fclose(fp1);
fclose(fp2);
printf("拷贝成功\n");
fp2=fopen("./2.txt","r");
if(fp2==NULL)
{
perror("fp2");
return -1;
}
char lll[100];
fgets(lll,sizeof(lll),fp2);
fputs(lll,stdout);
putchar(10);
fclose(fp2);
return 0;
}