title: SHELL, Save echo's output in to a file (c code)?
body: <p>I was trying to write a shell program(in c) and came across the following problem. Can any one please tell me how can I save the output of an <code>echo</code> in to a file. For example, some one might type in <code>echo document_this &gt; foo1</code> then I want to save <code>document_this</code> in to a file name foo1.</p>
  
  <pre><code>if(strcmp(myargv[0],"echo") == 0)
  {
     printf("Saving: %s in to a file", myargv[1]);
     .
     .
     .
  }
  </code></pre>
  
  <p>Any help would be greatly appreciated. can't use <code>#include &lt;fstream&gt;</code>, anything else I should use? Thanks.</p>