debug assertion failed

vs2008 调试报错

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
FILE *fp,*ofp;
void filecopy(FILE *,FILE *);
if(argc == 1)
filecopy(stdin,stdout);
else
while(--argc>0)
if((fp=fopen(*++argv,"r"))==NULL) //出错位置:此处是数组指针因写为*(argv+1)
printf("cat:can't open %s ",*argv);
else{
if((ofp=fopen(*++argv,"a+"))==NULL)
printf("cat:can't open %s ",*++argv);
else
filecopy(fp,stdout);
//fclose(fp);
}
}

void filecopy(FILE * ifp,FILE * ofp)
{
int c;
while((c=getc(ifp))!=EOF)
putc(c,ofp);

}

原文地址:https://www.cnblogs.com/zhangxiujun/p/3876761.html