|
From: Ramana K. <ra...@my...> - 2002-06-20 13:15:43
|
thanks very much
i would have been a little disturbed too. i am not too familiar with the
workings of command line arguments and was just copying a bit out of a text
book.
thanks for correcting me
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...]On Behalf Of Mac
Reiter
Sent: Thursday, 20 June 2002 2:47 AM
To: C++
Subject: RE: [Dev-C++] 2 questions
I'm a little disturbed by the description given below. I'm pretty sure
that argc includes the name of the executable, so that "bot.exe level3.bot"
would have argc == 2. I know that argv[0] contains the name of the
executable, because UN*X systems use this to distinguish behaviors for
symlinked executables (don't ask, it isn't possible on Windows, and it is
slightly odd anyway). The practical upshot is that, for the example above,
argv[0] would be "bot.exe" and argv[1] would be "level3.bot".
At 10:19 PM 6/19/02 +1000, Ramana Kumar wrote:
>to start a program using command line arguments, you take these two
>arguments in your main function.
>example:
>---------------------------------
>int main(int argc, char *argv[])
>{
> if(argc == 1)
> {
> openfile(argv[0]);
> }
> return 0;
>}
>---------------------------------
>the first argument passed to main (argc) is the number (int) of words typed
>after the name of the program when it is run. the second argument is an
>array of pointers to char strings, basically, a list in order of all the
>words passed to the program when it is run. in your example "bot.exe
>level3.bot" argc would equal 1 and argv[0] would evaluate as "level3.bot".
>so you could use a function (like openfile(char*) above) or even use
>ifstream in(argv[0]); or whatever else your program needs to use the
>filename given when your program is run.
>-----Original Message-----
>From: dev...@li...
>[mailto:dev...@li...]On Behalf Of Nils
>Langner
>Sent: Wednesday, 19 June 2002 2:27 AM
>To: dev...@li...
>Subject: [Dev-C++] 2 questions
>
>
>Hi,
>
>can somebody answer me a few questions ? My first problem is
>I compiled a console program and want to start it like this "bot.exe
>level3.bot"
>is it possible to configure dev-c++ o use these parameters ?
>
>my second question concerns the classbrowser, is it possible to
>move around in the .cc file or does it only support to move around in
>the header ?
>
>yours nils
>
>
>---------------------------------------------------------------------------
-
> Bringing you mounds of caffeinated joy
> >>> http://thinkgeek.com/sf <<<
>
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
>
>---------------------------------------------------------------------------
-
> Bringing you mounds of caffeinated joy
> >>> http://thinkgeek.com/sf <<<
>
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
-
_____________________________ /"\
Mac Reiter \ / ASCII Ribbon Campaign
Nomadics, Inc. X Against HTML Mail
re...@no... / \ (To join the campaign, simply use
this in your signature.)
----------------------------------------------------------------------------
Bringing you mounds of caffeinated joy
>>> http://thinkgeek.com/sf <<<
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|