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
Drittes Argument von main()
Re: Drittes Argument von main()
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
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
Re: Drittes Argument von main()
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
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
Re: Drittes Argument von main()
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-->
// 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-->