env[] in main()

This is a discussion on env[] in main() within the C Programming forums, part of the General Programming Boards category; referring to http://www.math.ntnu.no/~hrue/GMRFsi...ple-approx-2.c i fount the main() to be as Code: int main(int argc, char **argv, char **env) Can someone ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    99

    env[] in main()

    referring to http://www.math.ntnu.no/~hrue/GMRFsi...ple-approx-2.c

    i fount the main() to be as

    Code:
    int main(int argc, char **argv, char **env)
    Can someone explain me, where is env used and for what purpose?

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    in certain borland compilers and maybe others, it's used to pass environment variables to the program. It's non-standard though. See the faq.

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    99
    See the faq.[/QUOTE]

    from the FAQ :-

    Code:
    int main(int argc, char *argv[], char *envp[])

    shouldnt it be char *env[] than char *envp[] ??

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    as long as the types are the same, it doesn't really matter.
    int main(int sdgf, char *dslkgjf[])
    would work too, it's just convention.
    Last edited by robwhit; 06-17-2007 at 03:32 PM.

  5. #5
    Registered User
    Join Date
    Jun 2007
    Posts
    99
    Quote Originally Posted by robwhit View Post
    as long as the types are the same, it doesn't really matter.


    would work too, it's just convention.
    yeah rite, thanx

  6. #6
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    See MSDN too, they provide a pretty good explanation: http://msdn2.microsoft.com/en-us/lib...sc(VS.71).aspx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. passing params to main()
    By mike11 in forum C++ Programming
    Replies: 14
    Last Post: 06-21-2005, 12:36 PM
  2. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  3. Int Main or Void Main?
    By FromHolland in forum C++ Programming
    Replies: 9
    Last Post: 06-12-2003, 04:29 PM
  4. int main (), main (), main (void), int main (void) HELP!!!
    By SmokingMonkey in forum C++ Programming
    Replies: 7
    Last Post: 05-31-2003, 09:46 PM
  5. getting a function to return to main??
    By Neildadon in forum C++ Programming
    Replies: 7
    Last Post: 12-16-2002, 09:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21