#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(int argc, const char *argv[])
{
if(argc != 2)
{
return -1;
}
FILE * fp;
if((fp = fopen(argv[1],"r")) == NULL)
{
perror("fopen error");
return -1;
}
char buf[244];
int count = 0;
while((fgets(buf,10000,fp)) != NULL)
{
if(buf[strlen(buf) - 1] == '\n')
{
count++;
}
}
fclose(fp);
printf("%d\n",count);
return 0;
}
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(int argc, const char *argv[])
{
if(argc !=3)
{
return -1;
}
FILE * fp1;
if((fp1 = fopen(argv[1],"r")) == NULL)
{
return -1;
}
FILE * fp2;
if((fp2 = fopen(argv[2],"w")) == NULL)
{
return -1;
}
char buf[1323];
while((fgets(buf,10000,fp1)) != NULL)
{
fputs(buf,fp2);
}
fclose(fp1);
fclose(fp2);
return 0;
}