#include
#include
int main(int argc, char *argv[])
{
int ch;
errno_t err;
FILE *source, *destination;
if ((err = fopen_s(&source, argv[1], "rb") )!=0)
{
printf("can't open %s\n", argv[1]);
exit(1);
}
if ((err = fopen_s(&destination, argv[2], "wb")) != 0)
{
printf("can't open %s \n", argv[2]);
exit(1);
}
while ((ch = getc(source)) != EOF)
putc(ch, destination);
fclose(source);
fclose(destination);
printf("copy finished\n");
return 0;
}
C语言,用命令行参数复制文件,请问哪里出错了
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- ysuwood 2015-12-05 06:43关注
while ((ch = fgetc(source)) != EOF)//修改为fgetc fputc(ch, destination); //修改为fputc
解决 无用评论 打赏 举报