blob: f3a86db92a2aa6001a8c0af9ae1a74edb2178621 [file] [log] [blame]
<html lang="en">
<head>
<title>getenv - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Stdlib.html#Stdlib" title="Stdlib">
<link rel="prev" href="exit.html#exit" title="exit">
<link rel="next" href="labs.html#labs" title="labs">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="getenv"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="labs.html#labs">labs</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="exit.html#exit">exit</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a>
<hr>
</div>
<h3 class="section">2.18 <code>getenv</code>&mdash;look up environment variable</h3>
<p><a name="index-getenv-31"></a><a name="index-environ-32"></a><strong>Synopsis</strong>
<pre class="example"> #include &lt;stdlib.h&gt;
char *getenv(const char *<var>name</var>);
</pre>
<p><strong>Description</strong><br>
<code>getenv</code> searches the list of environment variable names and values
(using the global pointer &ldquo;<code>char **environ</code>&rdquo;) for a variable whose
name matches the string at <var>name</var>. If a variable name matches,
<code>getenv</code> returns a pointer to the associated value.
<p><br>
<strong>Returns</strong><br>
A pointer to the (string) value of the environment variable, or
<code>NULL</code> if there is no such environment variable.
<p><br>
<strong>Portability</strong><br>
<code>getenv</code> is ANSI, but the rules for properly forming names of environment
variables vary from one system to another.
<p><code>getenv</code> requires a global pointer <code>environ</code>.
<p><br>
</body></html>