title: UMASK function in C
body: <pre><code>#include&lt;stdio.h&gt;
  #include&lt;sys/types.h&gt;
  #include&lt;sys/stat.h&gt;
  void main()
  {
      umask(0000);
      creat("a.txt",666);
  }
  </code></pre>
  
  <p>My expected output is, the file created with the name "a.txt" with the permission as "rwrwrw". But, the output is as follows. </p>
  
  <p>Output:</p>
  
  <pre><code>$ ls -l a.txt 
  --w--wx-wT 1 mohanraj mohanraj 0 Sep 11 19:04 a.txt
  $
  </code></pre>
  
  <p>The umask is set to 0. So, I expected the file is created with the default file permission with 666. But, it gives some other output. So, 
  How umask internally worked. And How do I get the expected result.  </p>