Re: how to write a program that takes arguments from commandline?
- From: Martin Jørgensen <unoder.spam@xxxxxxxxxxxx>
- Date: Sun, 12 Feb 2006 15:23:41 +0100
Keith Thompson wrote:
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.
If the arguments isn't space-separated, how else would they be separated?
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.
Just as I thought.
Med venlig hilsen / Best regards
Martin Jørgensen
--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
.
- Follow-Ups:
- Re: how to write a program that takes arguments from commandline?
- From: Mark McIntyre
- Re: how to write a program that takes arguments from commandline?
- From: Keith Thompson
- Re: how to write a program that takes arguments from commandline?
- From: William J. Leary Jr.
- 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
- Re: how to write a program that takes arguments from commandline?
- From: Keith Thompson
- how to write a program that takes arguments from commandline?
- Prev by Date: Re: Segmentation fault!
- Next by Date: Re: how to write a program that takes arguments from commandline?
- 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
|