title: error handling mkdir and chdir in C?
body: <p>I do not understand why after creating directory <strong>mkdir</strong> return different values. In this example i'm trying to make a directory <strong><em>if not</em></strong> so error handle <strong><em>otherwise</em></strong> go to this directory <strong><em>if not</em></strong> so error handle.</p>
  
  <p>But it's not working as I want!
  It shows me 'failed to create' but actually creates the directory.
  If I read reference right it returns 0 when successes.</p>
  
  <p><em>Code:</em></p>
  
  <pre><code>    char* dirName = "Output";
      FILE *output;
  
      if(!mkdir(dirName))
          if(chdir(dirName))
              printf("Permission to open a new directory is denied");
      else
          printf("Permission to create a new directory is denied");
  </code></pre>