
C语言,用命令行参数复制文件,这代码哪里错了,怎么总是提示打不开
#include<stdio.h>#include<stdlib.h>intmain(intargc,char*argv[]){intch;errno_terr;FILE...
#include <stdio.h>
#include <stdlib.h>
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;
} 展开
#include <stdlib.h>
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# 命令行参数
1.如果是csc.exe的,请自行用/?查看
2.如果指你要给你自己写的程序的,那么Main的()里的参数LIST就是你要
与一般字符串数组使用一样
1.如果是csc.exe的,请自行用/?查看
2.如果指你要给你自己写的程序的,那么Main的()里的参数LIST就是你要
与一般字符串数组使用一样
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询