Re: how to write a program that takes arguments from commandline?
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Sat, 11 Feb 2006 23:40:17 GMT
Martin Jørgensen <unoder.spam@xxxxxxxxxxxx> writes:
stathis gotsis wrote:
-snip-
Maybe this is relevant:
http://c-faq.com/misc/argv.html
Thanks. That looks exactly like the place to start. Also thanks to the
other answers. I assume argc contains the number of (space-separated)
arguments.
The arguments aren't necessarily space-separated; that depends on the
mechanism (for example, a shell) used to invoke your program.
argc is the number of valid elements of the array pointed to by argv.
If you invoke your program with 2 command-line arguments, argc will be 3.
argv[0] probably points to (some form of) the name of your program;
argv[1] and argv[2] point to your command-line arguments.
--
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.
.
- Follow-Ups:
- Re: how to write a program that takes arguments from commandline?
- From: Martin Jørgensen
- Re: how to write a program that takes arguments from commandline?
- References:
- how to write a program that takes arguments from commandline?
- From: Martin Jørgensen
- Re: how to write a program that takes arguments from commandline?
- From: stathis gotsis
- Re: how to write a program that takes arguments from commandline?
- From: Martin Jørgensen
- how to write a program that takes arguments from commandline?
- Prev by Date: Re: size_t and C90/C99
- Next by Date: Programming Competition With Prize
- Previous by thread: Re: how to write a program that takes arguments from commandline?
- Next by thread: Re: how to write a program that takes arguments from commandline?
- Index(es):
Relevant Pages
|