home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 13146 < prev    next >
Encoding:
Text File  |  1992-09-02  |  1.5 KB  |  38 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!ferkel.ucsb.edu!piggy!chupchup
  3. From: chupchup@ferkel.ucsb.edu (Robert Earl)
  4. Subject: Re: main()
  5. Message-ID: <chupchup.715509038@piggy>
  6. Organization: (EVIL!)
  7. References: <715416182@Isis.MsState.Edu> <6700001@tisdec.tis.tandy.com>
  8. Date: Thu, 3 Sep 1992 08:30:38 GMT
  9. Lines: 27
  10.  
  11. doug@tisdec.tis.tandy.com writes:
  12.  
  13.  
  14. | Actually main() is defined as
  15. |   int main(int argc, char **argv, char *envp);
  16.  
  17. (I'm assuming "char *envp" was a typo of "char **envp").  Not in ANSI
  18. it isn't.  There's no such thing as "envp".  If your system refuses to
  19. translate a program without the envp declaration, it's not
  20. ANSI-conforming.
  21.  
  22. | Argc is the number of arguments on the command line, with the program
  23. | name counting as one, argv is a pointer to an array of pointers to the
  24. | arguments (program name is argv[0]), and envp is a pointer to array of
  25. | pointers to the program's environment variables.  This last is very
  26. | rarely used so you will usually see it prototyped with only 2 parameters.
  27.  
  28. It's very rarely used in UNIX, particularly, because the startup
  29. routine stuffs envp in a global variable called "environ", probably so
  30. main() doesn't have to do it all the time.  But "environ" doesn't
  31. exist in ANSI only getenv() and putenv(), and this is comp.lang.c.  :-)
  32.  
  33. -- 
  34. "If you've got a pig that likes jumping fences, | robert earl
  35. you have to make its fence a lot higher all at  | rearl@ucsd.edu
  36. once -- if you do it by increments, all you're  | rearl@piggy.ucsb.edu
  37. doing is training a jumping pig." -Henry Spencer|
  38.