Drittes Argument von main()

Post Reply
Message
Author
bakunin
Posts: 597
Joined: 16. Aug 1999 6:44
Location: Lorsch (Südhessen)
Contact:

Drittes Argument von main()

#1 Post by bakunin »

Hi!

Neben argc und argv kann man noch ein weiteres Argument nennen, um an die Umgebungsvariablen zu kommen (Das man an die auch anders rankommt weiß ich). Ich frage mich, ob das in irgendeinem Standard steht und in welchem und wie portabel das ist. Kann man davon ausgehen, dass jedes halbwegs moderne Unix diese Möglichkeit bietet?

Cheers,
Wolfgang

tHepLaYer

Re: Drittes Argument von main()

#2 Post by tHepLaYer »

Hi,

laut ANSI C hat die MAIN function max 2 parameter (argc & argv) das dritte

wird zwar noch bei einige compilern unterstzützt ist aber in ANSI C nicht

vorgesehen.


regards
tHepLaYer

bakunin
Posts: 597
Joined: 16. Aug 1999 6:44
Location: Lorsch (Südhessen)
Contact:

Re: Drittes Argument von main()

#3 Post by bakunin »

Hi!

Huch, da wurde ja ein ganz schön alter Thread wieder ausgegraben. <img src="http://www.pl-forum.de/UltraBoard/Images/Happy.gif" border="0" align="middle"> Aber danke für die Antwort, den die Frage war tatsächlich bis heute offen geblieben.

Cheers,
GNU/Wolfgang

Descartes

Re: Drittes Argument von main()

#4 Post by Descartes »

For instance, a common extension is to allow for the direct processing of environment variables. Such capability is available in some OS's such as UNIX and MS-Windows. Consider:

// L: Common extension, not standard
int main(int argc, char *argv[], char *envp[])

That said, it's worth pointing out that you should perhaps favor getenv() from stdlib.h in C, or cstdlib in C++, when you want to access environment variables passed into your application. (Note this is for reading them, writing environment variables so that they are available after your application ends are tricky and OS specific.)

siehe <a href="http://www.comeaucomputing.com/techtalk/#voidmain" target="_blank"><!--auto-->http://www.comeaucomputing.com/techtalk ... <!--auto-->

Post Reply