argv" -- C Language" "

Argument passed to main()

char *argv[];

argv is an abbreviation for ``argument vector''. It is the traditional name for a pointer to an array of string pointers passed to a C program's main function; by convention, it is the second argument passed to main. By convention, argv[0] always points to the name of the command itself.


This example demonstrates both argc and argv[], to recreate the command echo.
main(argc, argv)
int argc; char *argv[];
     int i;
     for (i = 1; i < argc; ) {
          printf("%s", argv[i]);
          if (++i < argc)
               putchar(' ');

See Also