A
Anonymous
Nick said:not really. There are plenty of ways to write to stdout.
There's only one way to read an environmental variable
<pedantic> using the stanadrard library </pedantic>.
The OP made it clear that he isn't interested in using the
standard library on this occasion. If he had asked "What's
the best way to access an environment variable in a
reasonably portable manner?" my answer would have been
"Use getenv() - but please be aware that the C standard
leaves so much implementation-defined in this regard that,
depending on what exactly you're wanting to do and your
target audience, it's possible your net portability gain
over using a platform-specific solution isn't all that
great."
In fact, I think that, *practically* speaking, anything the
standard declares as implementation-defined may as well just
have been declared as undefined when it comes to *real-world*
programming in heterogeneous environments - the reason being
that if you have to look at a bunch of implementations'
documentation manuals anyway, you may as well use the best
implementation-specific solution in each case.
Yes, I think from now on I too will be a pedant and advise
against all programming that relies on implementation-defined
properties or behaviors for which you may have to check
implementation documentation. The first victim will be
fopen().
Yours,
Han from China