title: How to take data from one file and put it into another in C
body: <p>Here is the code</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void)
  {
      int a, b,sum;
      FILE *in; 
      FILE *out; 
  
      in=fopen(&quot;numbers.txt&quot;,&quot;r&quot;);
      out=fopen(&quot;sums.txt&quot;,&quot;w&quot;);
  
      if(in== || out==NUll){
  
          printf(&quot;File open failed.\n&quot;);
          return 0;
      }
      else{
          fscanf(in,&quot;%d %d&quot;,&amp;a,&amp;b);
          sum=a+b;
          fprintf(out,&quot;%d %d %d&quot;,a,b,sum);
          fclose(in);
          fclose(out);
      }
  
      return 0;
  }
  </code></pre>
  <p>numbers.txt is in the form</p>
  <pre><code>a b
  a b
  etc..
  </code></pre>
  <p>so i am trying to take a and b and then inside sums.txt print out a, b and then the sum of the two.
  thanks.</p>