Re: how to design an testing example
- From: rlb@xxxxxxxxxxxxxxxxxxxxxx (Richard Bos)
- Date: Tue, 31 Oct 2006 14:32:02 GMT
qazwsx746@xxxxxxxx wrote:
The content of my program are the following:
#include <stdio.h>
int main(int argc,char *argv[])
{ FILE *fp;
void filecopy(FILE *,FILE *);
if (argc==1)
filecopy(stdin,stdout);
else
while (--argc>0)
if ((fp=fopen(*++argv,"r"))==NULL) {
printf("cat:can't open %s\n",*argv);
return 1;
} else {
filecopy(fp,stdout);
fclose(fp);
}
return 0;
}
void filecopy(FILE *ifp,FILE *ofp)
{int c;
while ((c=getc(ifp))!=EOF)
putc(c,ofp);
}
when I input command lines,for example:cat f:\test\1.cpp (windows xp
is installed in my computer)
the output are :cat f:\test\1.cpp
The angrument which is f:\test\1.cpp donot have work,and output is cat
f:\test\1.cpp
I know the program have no problem.
But I can't run the program corretly?
What should I do?
Call it correctly. The program is correct. It would be too much to say
that it has no problems, since it is horribly formatted, but it is at
least correct. I can compile it and run it, and it works both with stdin
and with a file I specify. Are you absolutely sure the filename you give
it is correct? Try the same command with type instead of cat, and see if
that does show up.
Richard
.
- Prev by Date: Re: EOF vs. feof() and ferror()
- Next by Date: Re: if clause
- Previous by thread: Re: C Interview Questions
- Next by thread: Re: how to design an testing example
- Index(es):
Relevant Pages
|