Mail Archives: djgpp/1998/07/29/08:30:38
From: | "Böhme Uwe" <uwe AT hof DOT baynet DOT de>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: please help {newbie}
|
Date: | Wed, 29 Jul 1998 12:57:40 +0200
|
Organization: | Bingo (Buergernetz Ingolstadt eV)
|
Lines: | 24
|
Message-ID: | <35BF0024.B4BCDF87@hof.baynet.de>
|
References: | <6pmncl$pph$1 AT osprey DOT global DOT co DOT za>
|
NNTP-Posting-Host: | port29.hof.baynet.de
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
> how do i read a file name to the program in the calling statement i.e.
> "c:\resolve test.txt"
>
> thanks
> heinrich
If a program is called with command line arguments (or without) you'll
get two parameters passed to your main()
int main(int argc, char *argv[])
The argc argument keep the number of command line arguments (at least 1,
even if no argument is specified),
argv[0] is a pointer to a string wich is holding the path of the exe file
itself (i.e. "c:\resolve.exe").
In your example argc would be 2 and argvc[1] would point to "test.txt".
Additional arguments increase argc and the n'th argument can be read by
argv[ n - 1 ].
Good luck
Uwe
- Raw text -