Re: is this stadard C?

From: Keith Thompson (kst-u_at_mib.org)
Date: 02/22/05


Date: Tue, 22 Feb 2005 21:47:28 GMT


"E. Robert Tisdale" <E.Robert.Tisdale@jpl.nasa.gov> writes:
> Keith Thompson wrote:
>
>> Passing the extra parameter to main() is one way to do it.
>> Another is (I think) declaring "extern char *environ[];".
>> The latter is cleaner, IMHO.
>> Both, of course, are non-standard.
>
> getenv(const char *) *is* standard
> but you must know the environment variable name
> that you are looking for.

Yes, thank you for restating the obvious. In Alan Balmer's previous
article, to which I was responding, he wrote (and I quoted):

] If you know the name of the environment variable you're looking for,
] yes, it's easier to use getenv(). If, for some reason, you wanted to
] search the environment variables, the "char *env[]" form would be
] the way to do it.

You also snipped the "<OT>" and "</OT>" tags I had placed around my
comments.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <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.


Relevant Pages

  • Re: system call as variabe
    ... On 9 Jul 2008 at 21:50, Keith Thompson wrote: ... Using a pipe should work, ... unamefunction directly is cleaner and really no less portable. ...
    (comp.lang.c)
  • Re: Returning structures from functions.
    ... the reason for passing a pointer. ... Keith Thompson kst-u@xxxxxxx ... Nokia ...
    (comp.lang.c)
  • Re: String Reverse Question
    ... Joe Wright writes: ... You're checking whether s is null *after* passing it to strlen. ... Keith Thompson kst-u@mib.org ... Schroedinger does Shakespeare: "To be *and* not to be" ...
    (comp.lang.c)