title: getcwd() with pointer returns "null"
body: <p>I'm trying to recall a bit about C programming.</p>
  
  <p>And one task I found for myself - is to pass string's variable between functions with pointers.</p>
  
  <p>So - what I want to do:</p>
  
  <ul>
  <li>create an array;</li>
  <li>create a pointer to this array;</li>
  <li>pass pointer as an argument to another function;</li>
  <li>call <code>getcwd()</code> inside second function;</li>
  <li>print result.</li>
  </ul>
  
  <p>And here is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  
  int ch_str(char point1[]) {
      printf("Point 1: %s\n", point1);
  }
  
  int getpath (char point2[]) {
      printf("Path: %s\n", getcwd(point2, sizeof(point2)));
  }
  
  int main () {
  
      char str[20] = "this is string";
      char *pStr;
      pStr = &amp;str;
  
      ch_str(pStr);
  
      char pathname[1024];
      char *pPathname;
      pPathname = &amp;pathname;
  
      getpath(pPathname);
  
      printf("Direct: %s\n", getcwd(pathname, sizeof(pathname)));
  
      return 0;
  }
  </code></pre>
  
  <p><code>ch_str()</code> here - is just "test" for me, to be sure I'm doing right (he-he) with pointers. And - this part works.</p>
  
  <p>But <code>getcwd()</code> with pointer as an argument - just retun "null":</p>
  
  <blockquote>
  <pre><code>$ ./deploy
  Point 1: this is string
  Path: (null)
  Direct: /home/setevoy/ci
  </code></pre>
  </blockquote>
  
  <p>I suppose - here is some (big...) misunderstanding of the pointers in C from my side, but:</p>
  
  <blockquote>
    <p>The <code>getcwd()</code> function copies an absolute pathname of the current working directory to the array pointed to by buf</p>
  </blockquote>
  
  <p>Array (<code>pathname[1024]</code>) passed with the pointer <code>pPathname</code>, so - why <code>getcwd()</code> can't save path to <code>pathname[1024]</code> location? What I can't see here?</p>