making args global
Ali Çehreli
acehreli at yahoo.com
Tue Apr 3 15:44:08 PDT 2012
On 04/03/2012 03:32 PM, jicman wrote:
>
> Greetings.
>
> imagine this code...
>
> void c()
> {
> char [] t = args[0];
> }
> void main(char[][] args)
> {
> int i = 1;
> }
>
> How can I make args global?
>
> thanks,
>
> jose
First, the general discouragement: Avoid global data. :)
You can initialize a global variable upon entering main:
import std.stdio;
string[] g_args;
void foo()
{
writeln("Program name: ", g_args[0]);
}
void main(string[] args)
{
g_args = args;
foo();
}
Ali
More information about the Digitalmars-d-learn
mailing list