Gast
#6957805
Hallo, ich habe ein "Hello World" Programm, das ich mit MinGw kompiliere. Leider werden die Kommandozeilen Argumente nicht erkannt und beim Kompilieren auch ignoriert. Das Programm endet mit der ersten Nutzung von argc. Wie kann ich die Kommandozeilen Argumente sichtbar machen ? ------------ gcc gcc (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ------------ mingw32-make GNU Make 4.2.1 Built for i686-w64-mingw32 Copyright (C) 1988-2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. ------------ Code #include <stdio.h> int main(int argc, char *argv[]) { printf("Hello, World !"); int i=0; printf("\nindex=%u", i); printf("\ncmdline args count=%s", argc); /* First argument is executable name only */ printf("\nexe name=%s", argv[0]); for (i=1; i< argc; i++) { printf("\narg%d=%s", i, argv[i]); } printf("\n"); return 0; } ------------ Ausgabe beim Kompilieren echo hello world hello world gcc main.c -o hello.exe ------------ Aufruf von hello.exe: ...>hello 1 2 3 Hello, World ! index=0 *keine weiteren Ausgaben, das Programm endet mit der ersten Nutzung von argc