title: what is the difference between extern char **environ and extern char *environ[]
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  
  extern char *environ[];
  int main(int argc, char *argv[])
  {
      int index = 0;
      char **env = environ;
      printf("Environment variables:\n");
      index = 0;
      while (env[index])
      {
          printf("envp[%d]: %s\n", index, env[index]);
          ++index;
      }
      return 0;
  }
  </code></pre>
  
  <p>output:  </p>
  
  <pre><code>Environment variables:  
  envp[0]: GH#þ 
  </code></pre>
  
  <p>I want to print all the environments, but it can't work.<br>
  I changed <code>extern char *environ[]</code> to <code>extern char **environ</code> and it can print all the environments.<br>
  After changing the code output:</p>
  
  <pre><code>Environment variables:
  envp[0]: XDG_SESSION_ID=8
  envp[1]: TERM=xterm
  envp[2]: SHELL=/bin/bash
  envp[3]: SSH_CLIENT=192.168.1.224 1085 22
  envp[4]: SSH_TTY=/dev/pts/0
  ...
  </code></pre>