Following a program which echos whatever you type in the command line.
#include <stdio.h>
main(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 vectors. Each word is a string. So if you type:
myprogram.exe my input
the output should be
argv[0] = myprogram.exe
argv[1] = my
argv[2] = input
The terms argc and argv are used by convention.