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.

Reply via email to