problem with args

Chris Paterson chris at paterson.bz
Sat Sep 15 00:46:30 PDT 2007


I can't see what's going wrong here.  Compiling this program:
===
import std.stdio;
import std.conv;

int main(char[][] args)
{
    if (args.length > 0) {
        const int max = std.conv.toInt(args[1]);
        writefln("max=%d", max);
    }
    return 0;
}
===
with "dmd args_test.d"
gives an error message:
"Error: variable args is used before initialization"
with no line number or any other information.

It's the line:
        const int max = std.conv.toInt(args[1]);
that causes the problem.

What am I missing here?

Thanks,
Chris.




More information about the Digitalmars-d mailing list