Re: how to design an testing example



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);
}

I really don't understand what you're saying. Could you state what
input
you gave your program, what output you expected and what output you
expected.

This may be exactly what you intended to do, but it was not clear to
me.

Try formatting it like this:
input: cat f:\test\1.cpp
expected: cat f:\test\1.cpp
actual: ???


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 can't see which is the expected and which the actual output

I know the program have no problem.

excellent! So you have no problem? :-)

But I can't run the program corretly?
What should I do?


--
Nick Keighley

.



Relevant Pages

  • Re: how to design an testing example
    ... int main ... void filecopy ... when I input command lines,for example:cat f:\test\1.cpp (windows xp ... The angrument which is f:\test\1.cpp donot have work,and output is cat ...
    (comp.lang.c)
  • Re: preprocessor/linker c++ error
    ... $ cat file1.cc ... void f1(int x,int y, int z) ... Novell's Directory Services is a competitive product to Microsoft's ...
    (Debian-User)
  • Re: how to design an testing example
    ... int main ... void filecopy ... The angrument which is f:\test\1.cpp donot have work,and output is cat ... A backslash character is ...
    (comp.lang.c)
  • Re: Classes
    ... "Missing identifier before 'Cat' " should make you look carefully at what's ... > int getAge(); ... > void setAge; ... > int itsAge; ...
    (microsoft.public.vc.language)
  • Re: sqrt: DOMAIN error
    ... Nick Keighley said: ... <several style crits, such as...> ... int main (void) ...
    (comp.lang.c)