求指点:文件打不开
这个程序主要实现文件复制,我将文件路径通过赋值的方式传递给子函数。附件为文件路径。结果运行时:提示两个文件都打不开;
#include<stdio.h>
#include<stdlib.h>
void thirteen_one(void);
void thirteen_two(int argc,char *argv[]);
void main(void)
{
int argc = 3;
char *argv[3];
argv[0] = "thirteen.exe";
argv[1] = "d:\file\thirteen";
argv[2] = "d:\file\thirteen_two";
thirteen_two(argc,argv);
}
/*13.2*/
void thirteen_two(int argc,char *argv[])
{
FILE *fp_in;
FILE *fp_out;
char ch;
if(argc != 3)
{
printf("Usage file %s sourcefile targetfile\n",argv[0]);
exit(1);
}
if((fp_out=fopen(argv[2],"w")) == NULL)
{
printf("could not open file %s\n",argv[2]);
exit(1);
}
if((fp_in=fopen(argv[1],"r")) == NULL)
{
printf("could not open file %s\n",argv[1]);
exit(1);
}
while((ch=getc(fp_in)) !=EOF)
{
fputc(ch,fp_out);
}
if(fclose(fp_in) !=0)
printf("cannot close file %s\n",argv[1]);
if(fclose(fp_out) !=0)
printf("cannot close file %s\n",argv[2]);
}