qfedu-c-level/day14/homework/h5.c

35 lines
703 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 设计函数, int filecpy(char *src_file, char *dst_file)的功能实现文件src_file备份到dst_file 如果成功返回 0 失败返回 1
#include <stdio.h>
int filecpy(char *src_file, char *dst_file)
{
FILE *aF = fopen(src_file, "rb");
FILE *bF = fopen(dst_file, "wb");
if (NULL == aF)
{
perror("src_file fopen");
return 1;
}
if (NULL == bF)
{
perror("dst_file fopen");
return 1;
}
int temp_c = fgetc(aF);
while (temp_c != EOF)
{
fputc(temp_c, bF);
temp_c = fgetc(aF);
}
fclose(aF);
fclose(bF);
return 0;
}
int main()
{
filecpy("score.txt", "sxxx.dest");
return 0;
}