whats the use of third argument to main( )

Discussion in 'C Programming' started by thesushant@rediffmail.com, Jan 11, 2005.

  1. Guest

    hi,

    whats the use of third argument to main( ), i.e. environmental
    parameters.... if i am not wrong ? 1st 1 is argc 2nd is argv and what
    bout the 3rd 1???????????

    sushant
    , Jan 11, 2005
    #1
    1. Advertising

  2. writes:
    > whats the use of third argument to main( ), i.e. environmental
    > parameters.... if i am not wrong ? 1st 1 is argc 2nd is argv and what
    > bout the 3rd 1???????????


    The C standard specifies that main can take no arguments:
    int main(void)
    or two arguments:
    int main(int argc, char **argv)

    Implementations are allowed to accept other forms, but such forms are
    non-standard and should probably be discussed in a newsgroup specific
    to the system you're using.

    One common extension is to accept a third argument that points to the
    environment:
    int main(int argc, char **argv, char **envp)

    The standard getenv() function provides some, but not all, of the
    functionality of this third argument. Some systems also make it
    available as an external variable called "environ". It's a pointer to
    an array of pointers to strings, each of the string represents an
    environment variable.

    Code intended to be maximally portable should only access the
    environment through the getenv() function.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Jan 11, 2005
    #2
    1. Advertising

  3. Guest

    thnx Keith for ur info .... can u elaborate on wht u mean by
    environment variables?
    , Jan 11, 2005
    #3
  4. Trent Buck Guest

    Trent Buck, Jan 11, 2005
    #4
  5. Mike Wahler Guest

    <> wrote in message
    news:...
    > thnx Keith for ur info .... can u elaborate on wht u mean by
    > environment variables?


    Some, but not all, operating systems provide 'environment
    variables' as a configuration mechanism, typically providing
    'global' data available to applications. If your operating
    system has them (e.g. MS-DOS and Windows have them), you
    can learn more by reading its documentation.

    -Mike
    Mike Wahler, Jan 11, 2005
    #5
  6. Neo Guest

    <> wrote in message
    news:...
    > hi,
    >
    > whats the use of third argument to main( ), i.e. environmental
    > parameters.... if i am not wrong ? 1st 1 is argc 2nd is argv and what
    > bout the 3rd 1???????????
    >
    > sushant


    main() can take at most two arguments.
    int main(int argc, char *argv[])
    {
    .....
    }

    There no third argument to main() in C.
    That can be some non-std. feature (implementation defined) which you may be
    talking of. Sorry C doesnt have such thing.

    -Neo
    Neo, Jan 11, 2005
    #6
  7. <posted & mailed>

    wrote:

    > hi,
    >
    > whats the use of third argument to main( ), i.e. environmental
    > parameters.... if i am not wrong ? 1st 1 is argc 2nd is argv and what
    > bout the 3rd 1???????????


    In C, main() takes at most 2 arguments.


    >
    > sushant


    --
    Remove '.nospam' from e-mail address to reply by e-mail
    James McIninch, Jan 11, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QXNoYQ==?=

    dispose and nothing? whats the main difference?

    =?Utf-8?B?QXNoYQ==?=, Jul 14, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,803
    Scott Allen
    Jul 14, 2004
  2. Replies:
    2
    Views:
    296
  3. Replies:
    3
    Views:
    392
  4. Lambda
    Replies:
    3
    Views:
    622
    Lambda
    Jun 24, 2008
  5. ±è ÁØ¿µ
    Replies:
    7
    Views:
    249
    Einar Magnús Boson
    Nov 27, 2008
Loading...

Share This Page