D as a Better C

Azi Hassan via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Wed Aug 30 15:24:15 PDT 2017


On Wednesday, 30 August 2017 at 22:22:23 UTC, Azi Hassan wrote:
> How should command-line arguments be used in better C ? Looping 
> through argv seems to print environment variables :
>
> import core.stdc.stdio;
>
> extern(C) int main(int argc, char*[] argv, char*[] env)
> {
> 	foreach(i; 0 .. argc)
> 		printf("arg %d: %s\n", i, argv[i]);
> 	return 0;
> }
>
>
> Compiling with v2.076.0-b2-dirty on Lubuntu 14.04 and running 
> with one argument outputs the following :
>
> arg 0: XDG_VTNR=7
> arg 1: LC_PAPER=fr_FR.UTF-8

Forgot to mention, char*[] env was only for testing purposes. The 
code still produces the same output with char*[] env omitted.


More information about the Digitalmars-d-announce mailing list