35 lines
703 B
C
35 lines
703 B
C
// 设计函数, 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;
|
||
} |