Re: how to design an testing example
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Tue, 31 Oct 2006 08:03:33 GMT
"Subbu" <mailursubbu@xxxxxxxxx> writes:
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?
While passing the file name use "\\" insted of "\".
Please don't top-post. See the following:
http://www.caliburn.nl/topposting.html
http://www.cpax.org.uk/prg/writings/topposting.php
That's not likely to be the problem. A backslash character is
represented as "\\" in a string literal or character constant in C
source code; the syntax doesn't necessarily apply to whatever provides
a program's command-line arguments. <OT>In particular, it's not
likely to apply on Windows.</OT>
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- References:
- how to design an testing example
- From: qazwsx746
- Re: how to design an testing example
- From: Subbu
- how to design an testing example
- Prev by Date: Re: assembly in future C standard
- Next by Date: Re: assembly in future C standard
- Previous by thread: Re: how to design an testing example
- Next by thread: realloc(): invalid next size
- Index(es):
Relevant Pages
|
|