IHYPRESS PROGRAMMING
Tutorials and C programs with code and output for beginners
c programming
HOME | ASP | C | CSS | GNUPLOT | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
CAdvanced Programming : String Command Line Arguments
<12.01>
/* Using command-line arguments */
#include <stdio.h> /* argc: number of arguments (always at least 1) */ /* argv: array of strings containg the arguments */ int main (int argc, char *argv[]) { int i; /* argument 0 identifies the program */ printf ("This program was called with \"%s\".\n",argv[0]); /* arguments from 1 are passed to the program */ /* displays the arguments as entered */ printf ("Arguments passed: "); for (i = 1; i < argc; ++i) printf("%s ", argv[i]); printf ("\n"); /* diaplays each idividual strings of arguments */ if (argc > 1) { for (i = 1; i < argc; ++i) printf("argv[%d] = %s\n", i, argv[i]); } else { printf("The command had no other arguments.\n"); } return (0); }
Hergestellt in Deutschland / Made in Germany
Microsoft(R) Windows DOS (C)Copyright Microsoft Corp 1990-2001. A:\> arg.exe the quick brown fox This program was called with "ARG.exe". Arguments passed: the quick brown fox argv[1] = the argv[2] = quick argv[3] = brown argv[4] = fox A:\>
COPYRIGHT © 2015-2024 IHY PRESS Frankfurt am Main 60329 Deutschland