#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
if(argc != 3)
{
printf("error");
}
FILE* f1 = fopen(argv[1], "r+");
if(NULL == f1)
{
perror("fopen");
return 1;
}
FILE* f2 = fopen(argv[2], "w+");
if(NULL == f2)
{
perror("fopen");
return 2;
}
char str1[1024] = {0};
int count = 0;
while(count = fread(str1, sizeof(char), 1024, f1))
{
if(-1 == count)
{
perror("fread");
fclose(f1);
fclose(f2);
return 4;
}
int count1 = fwrite(str1, sizeof(char), count, f2);
if(-1 == count1)
{
perror("fwrite");
fclose(f1);
fclose(f2);
return 5;
}
memset(str1, 0, 1024);
}
fclose(f1);
fclose(f2);
return 0;
}
#include <string.h>
int main(int argc, char* argv[])
{
if(argc != 3)
{
printf("error");
}
FILE* f1 = fopen(argv[1], "r+");
if(NULL == f1)
{
perror("fopen");
return 1;
}
FILE* f2 = fopen(argv[2], "w+");
if(NULL == f2)
{
perror("fopen");
return 2;
}
char str1[1024] = {0};
int count = 0;
while(count = fread(str1, sizeof(char), 1024, f1))
{
if(-1 == count)
{
perror("fread");
fclose(f1);
fclose(f2);
return 4;
}
int count1 = fwrite(str1, sizeof(char), count, f2);
if(-1 == count1)
{
perror("fwrite");
fclose(f1);
fclose(f2);
return 5;
}
memset(str1, 0, 1024);
}
fclose(f1);
fclose(f2);
return 0;
}