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? 6 1349
Hi,
While passing the file name use "\\" insted of "\".
Best Regards,
Subra.. qa*******@eyou.com 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?
Subbu said:
Hi,
While passing the file name use "\\" insted of "\".
No. File names might not even /have/ a \ character as part of their name. At
least as far as I'm aware, none of the files on my filesystem does, and
even if the OP's system does, the advice doesn't apply to the OP anyway.
The reason for using \\ instead of \ when you want a \ in astring literal
is nothing to do with files and everything to do with string literals.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
"Subbu" <ma*********@gmail.comwrites:
qa*******@eyou.com 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) ks***@mib.org <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. qa*******@eyou.com 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
On 30 Oct 2006 19:00:07 -0800, qa*******@eyou.com 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
There is no printf statement in your program which will produce this
output. What is the real output from your program?
>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?
These two statements are mutually exclusive. If the program had no
problem, it would run correctly.
>What should I do?
Remove del for email qa*******@eyou.com 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andrea Griffini |
last post by:
I did it.
I proposed python as the main language for our next CAD/CAM
software because I think that it has all the potential needed
for it. I'm not sure yet if the decision will get through, but...
|
by: francois |
last post by:
Hi everyone,
I'm new to webdesign and there are some things that I'm wondering.
Should I learn HTML hand crafting firt with CSS and then move to
Javascript or move to XHTML? Is HTML an essential...
|
by: max |
last post by:
Hello,
I analyze this design pattern for a long time but I do not understand how
this pattern work and what the purpose is? (I looked a this site...
|
by: JS |
last post by:
I'm trying to create a data layer and having problems returning a DataSet
from my code that's in a class module.
Please forgive me. I'm new to C# (VB'er). I decided to create my data layer
in...
|
by: zlst |
last post by:
Many technological innovations rely upon User Interface Design to elevate
their technical complexity to a usable product. Technology alone may not win
user acceptance and subsequent marketability....
|
by: limsy |
last post by:
Hi ppl,
Sorry for asking such a NEWBIE question. I tried looking for answers but
cant find. Maybe its too easy. :(
I'm used to manual code ADO rather than this .NET wizard and stuff... and i
am...
|
by: YellowFin Announcements |
last post by:
Introduction
Usability and relevance have been identified as the major factors
preventing mass adoption of
Business Intelligence applications. What we have today are traditional
BI tools that...
|
by: John Kraft |
last post by:
Friends,
I'm working on some crud stuff, and I was looking for opinions on the
subject. Below, I have pasted some VERY simple sample code. Class2
is a "traditional" crud type object. In a...
|
by: apollonius2 |
last post by:
Greetings,
I have been working on a little project today to help me better
understand classes in Python (I really like Python). I am a self
taught programmer and consider myself to fall in the...
|
by: Phlip |
last post by:
1230987za wrote:
Kanze is a classically-trained "unit tester". In some circles "unit" is a QA
concept - specifically, if a test fails, you only need to inspect one unit.
So "units" are...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |