title: Store output of system(file) command as a string in C
body: <p>To get the type of file we can execute the command </p>
  
  <pre><code>system("file --mime-type -b filename");
  </code></pre>
  
  <p>The output displays in to terminal.But could not store the file type using the command</p>
  
  <pre><code>char file_type[40] = system("file --mime-type -b filename");
  </code></pre>
  
  <p>So how to store file type as a string using system(file) function.</p>