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\n",*argv);
else{
if((ofp=fopen(*++argv,"a+"))==NULL)
printf("cat:can't open %s\n",*++argv);
else
filecopy(fp,stdout);
//fclose(fp);
}
}
void filecopy(FILE * ifp,FILE * ofp)
{
int c;
while((c=getc(ifp))!=EOF)
putc(c,ofp);
}