Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    int main( void );
    int main( int argc, const char *argv[] );

Description:
    The function main is a user-supplied function where program execution
    begins.  The command line to the program is broken into a sequence of
    tokens separated by blanks and are passed to main as an array of
    pointers to character strings in the parameter argv.  The number of
    arguments found is passed in the parameter argc.  The first element of
    argv will be a pointer to a character string containing the program
    name.  The last element of the array pointed to by argv will be a NULL
    pointer (i.e.  argv[argc] will be NULL).  Arguments that contain blanks
    can be passed to  main by enclosing them within double quote characters
    (which are removed from that element in the argv vector.

    The command line arguments can also be obtained in its original format
    by using the  getcmd function.

Returns:
    The function  main returns a return code back to the calling program
    (usually the operating system).

See Also:
    abort, atexit, _bgetcmd, exec Functions Functions, exit, _exit, getcmd, getenv,
    onexit, putenv, spawn Functions Functions, system

Example:
    #include <stdio.h>

    int main( int argc, char *argv[] )
      {
        int i;
        for( i = 0; i < argc; ++i ) {
          printf( "argv[%d] = %s\n", i, argv[i] );
        }
        return( 0 );
      }

    produces the following:

    argv[0] = C:\WATCOM\DEMO\MYPGM.EXE
    argv[1] = hhhhh
    argv[2] = another arg

    when the program mypgm is executed with the command

    mypgm hhhhh  "another arg"

Classification:
    ANSI

Systems:
    All

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson