title: redirect the stdout and stderr into a file
body: <p>I want to <strong>redirect</strong> the output of a <strong>system call</strong> into a <strong>file</strong>.. I tried this..</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
          system("ls &gt;&gt; temp.txt");
          return 0;
  }
  </code></pre>
  
  <p>But this is only working for <strong>system calls</strong>.. If i put some other thing in place of <code>ls</code>, the error output is not redirected into the file.. it is just printed on the <code>console</code>.. </p>
  
  <p>For example</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
  system("hello &gt;&gt; temp.txt");
  return 0;
  }
  </code></pre>
  
  <p>I want the error output redirected to the file.. how can i do this? thanks..</p>