

#include <head.h>
int main(int argc, const char *argv[])
{
FILE* fp=fopen("./1.c","r");
if(NULL==fp)
{
ERRLOG("fopen error");
}
printf("打开成功\n");
FILE*fp1=fopen("11.c","w");
if(NULL==fp1)
{
ERRLOG("fopen error");
}
char str[128]={0};
while(1)
{
if(NULL==fgets(str,sizeof(str),fp))
{
return -1;
}
if(EOF==fputs(str,fp1))
{
return -1;
}
}
if(EOF==fclose(fp))
{
ERRLOG("fclose error");
}
if(EOF==fclose(fp1))
{
ERRLOG("fclose error");
}
return 0;
}

//计算行数
#include <head.h>
int main(int argc, const char *argv[])
{
FILE* fp=fopen("./xixi","r");
if(NULL==fp)
{
ERRLOG("fopen error");
}
printf("打开成功\n");
char str[128]={0};
int count=0;
while(1)
{
if(NULL==fgets(str,sizeof(str),fp))
{
printf("%d\n",count);
return -1;
}
count++;
}
if(EOF==fclose(fp))
{
ERRLOG("fclose error");
}
return 0;
}
