Question: 7. What is the output of this program?<div class="hk1_style-wrap4"><div class="hk1_style-wrap3"><div class="hk1_style-wrap2"><div class="hk1_style-wrap"><div class="hk1_style"><div class="c"><ol><li class="li1"><pre class="de1"> <span class="co2">#include&lt;stdio.h&gt;</span></pre></li><li class="li1"><pre class="de1"> <span class="co2">#include&lt;sys/types.h&gt;</span></pre></li><li class="li1"><pre class="de1"> <span class="co2">#include&lt;sys/un.h&gt;</span></pre></li><li class="li1"><pre class="de1"> <span class="co2">#include&lt;sys/socket.h&gt;</span></pre></li><li class="li1"><pre class="de1"> <span class="co2">#include&lt;errno.h&gt;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1"> <span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> <span class="kw4">struct</span> sockaddr_un addr<span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw4">int</span> fd<span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> fd <span class="sy0">=</span> socket<span class="br0">(</span>AF_UNIX<span class="sy0">,</span>SOCK_STREAM<span class="sy0">,</span><span class="nu0">0</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">if</span> <span class="br0">(</span>fd <span class="sy0">==</span> <span class="sy0">-</span><span class="nu0">1</span><span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="kw3">perror</span><span class="br0">(</span><span class="st0">"socket"</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> addr.<span class="me1">sun_family</span> <span class="sy0">=</span> AF_UNIX<span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw3">strcpy</span><span class="br0">(</span>addr.<span class="me1">sun_path</span><span class="sy0">,</span><span class="st0">"san_sock"</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">if</span> <span class="br0">(</span>bind<span class="br0">(</span><span class="nu0">4</span><span class="sy0">,</span><span class="br0">(</span><span class="kw4">struct</span> sockaddr<span class="sy0">*</span><span class="br0">)</span><span class="sy0">&amp;</span>addr<span class="sy0">,</span><span class="kw4">sizeof</span><span class="br0">(</span>addr<span class="br0">)</span><span class="br0">)</span> <span class="sy0">==</span> <span class="sy0">-</span><span class="nu0">1</span><span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="kw3">printf</span><span class="br0">(</span><span class="st0">"Sanfoudnry<span class="es1">\n</span>"</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">return</span> <span class="nu0">0</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span></pre></li></ol></div></div></div></div></div></div>
Options:
this program will print the string “Sanfoundry”
this program will not print the string “Sanfoundry”
segmentation fault
none of the mentioned
Answer: A