ore.exception.RangeError

Moritz Maxeiner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 23 04:18:14 PDT 2017


On Wednesday, 23 August 2017 at 05:53:46 UTC, ag0aep6g wrote:
> On 08/23/2017 07:45 AM, Vino.B wrote:
>> Execution :
>> rdmd Summary.d - Not working
>> rdmd Summary.d test - Working
>> 
>> Program:
>> 
>> void main (string[] args)
>> {
>>   if(args.length != 2 )
>>      writefln("Unknown operation: %s", args[1]);
>> }
>
> When args.length == 1, then the one element is args[0], not 
> args[1].
>
> args[1] only exists when args.length >= 2.

To expand on that: argv[0] is what is passed to the process the D 
program runs at in the system call it was spawned from (e.g. 
execve), which usually corresponds to the program's name.


More information about the Digitalmars-d-learn mailing list