File I/O

  • Thread starter Papadopoulos Giannis
  • Start date
M

Mike Wahler

Peter Nilsson said:
...
argc = 6; and argv[] = { "myprog", "i", "am", "a", "c", "freak" };

Not necessarily. The first element could be "\0";

True, but I think it's more likely to be "" than "\0", although I can't
really justify the statement in any objective fashion. <g>

Sloppy presentation on my part. I did mean an 'empty string',
but was trying to be clearer by inserting the '\0' character.
Not the first time one of my attempts at clarity resulted
in the opposite. :)

-Mike
 
T

those who know me have no need of my name

in comp.lang.c i read:
A minor point, which is now easily controlled (and seen). If the
user enters the same name for argv[1] and argv[2] opening the
'out' file could destroy the prospective 'in' file. Handling the
'in' file first usually gives some added assurance, because most
systems will refuse to open for write a file that is already open
for read.

`most systems'? well, some at least. comparing the filenames is about the
best you can do in a totally portable program (even this has flaws), only
then hoping that the system won't truncate a file already open for reading.
 
M

Mike Wahler

Bill Cunningham said:
In a UNIX or LINUX environment a directory will be listed. At least on my
linux OSs it's ls -la.

I think you've missed the point. In an 'ls' written in C,
That invocation would cause argc to have a value of 2,
argv[0] would be either "" or "ls", and argv[1] would
be "-l". IOW argc/argv is how the program retrieves
user supplied parameters.

-Mike
 
B

Bill Cunningham

I think you've missed the point. In an 'ls' written in C,
That invocation would cause argc to have a value of 2,
argv[0] would be either "" or "ls", and argv[1] would
be "-l". IOW argc/argv is how the program retrieves
user supplied parameters.

-Mike

I see.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,204
Latest member
LaverneRua

Latest Threads

Top