C/Unix: How to extract the bits from st_mode?
<p>I am a beginner to Unix programming and C and I have two questions regarding the <code>struct stat</code> and its field <code>st_mode</code>:</p>

<ol>
<li><p>When accessing the <code>st_mode</code> field as below, what type of number is returned( octal, decimal, etc.) ?</p>

<pre><code>struct stat file;
stat( someFilePath, &amp;file);
printf("%d", file.st_mode );
</code></pre></li>
</ol>

<p>I thought the number is in octal but when I ran this code, and I got the value <code>33188</code>. What is the base ?</p>

<ol start="2">
<li>I found out that the <code>st_mode</code> encodes a 16 bit binary number that represents the file type and file permissions. How do I get the 16-bit number from the above output(esp. when it doesn't seem to be in octal). And which parts of the 16-bit digit encodes which information ?</li>
</ol>

<p>Thanks for any help.</p>