怎么在VC++6.0中编译连接

来源:百度知道 编辑:UC知道 时间:2024/05/27 03:01:55
源代码 ----复制文件
#include"stdio.h"
#include"stdlib.h"
main(int argc,char *argv[])
{
FILE *fp1,*fp2;
char ch;
if((fp1=fopen(argv[1],"r"))==NULL)
{
printf("cannot open the file:%s\n",argv[1]);
exit(1);
}
if((fp2=fopen(argv[2],"w"))==NULL)
{
printf("cannot open the file:%s\n",argv[2]);
exit(2);
}
while(feof(fp1)==0)
{
ch=fgetc(fp1);
fputc(ch,fp2);
}
printf("\n");
fclose(fp1);
fclose(fp2);
}
怎么调试连接啊?? 执行就错误如图http://hi.baidu.com/sjj354/album/item/ce8091eb203376ced439c935.html
自学文件一块.....不知道编译器里怎么弄

在VC6的项目设置中的“调试->命令参数”处填写你的命令行参数(即复制的源文件、目标文件,中间用空格隔开),
如:"c:\a.txt d:\b.txt", 然后按F5启动调试程序运行直到断点处停止,或者F10单步调试程序,F9设置断点

注:你的程序出错,估计是没有填写命令行参数,所以出现在调用fopen打开文件时传入的文件名argv[1]为NULL的错误。

feof()
文件结束返回0,所以一般都用
while(!eof(fp))
{
*****
}