

argv                        C Language                       argv




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.

***** Example *****

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(' ');
        }



        putchar('\n');
        return 0;
}


***** See Also *****

argc, C language, envp, main()

















COHERENT Lexicon                                           Page 1


