Following a program which echos whatever you type in the command line.
#includemain(int argc, char *argv[]) { int i; for(i = 0; i < argc; i++) { printf("arg %d: %s\n", i, argv[i]); } return 0; }
argc is the count of the number of command-line arguments. argv is array of words. Each word is a string. So if you type:
myprogram.exe my input
argv[] would fill as follows:
argv[0] = myprogram.exe
argv[1] = my
argv[2] = input
The terms argc and argv are used by convention.