title: C, Call to function twice, one writes to file, one writes to terminal
body: <p>fairly new to C and have a slight issue,</p>
  
  <p>I have a function which is filled with 'fprintf' statements and some calculations relevant to the output.
  When I call it from main() it works correctly and prints to the document, I then want to call it a second time and have the same text but only outputted to the terminal (as in printf).</p>
  
  <p>I have a flag in the function parameters which would specify this choice but no way of accomplishing it aside from an if statement for every fprintf saying:</p>
  
  <pre><code>if (flag == 1)
  { 
      fprintf(pt, "Random text...
  } else { 
      printf("The same random text...
  }
  </code></pre>
  
  <p>Which seems dreadfully inefficient. My other idea was to (with my little understanding of it) use #define within the function in the context:</p>
  
  <pre><code>if (flag== 1)
  {
      #define fprintf(pt, printf(
  }
  </code></pre>
  
  <p>Which not only seemed very cheap but did not work.</p>
  
  <p>Any ideas would be appreciated,
  Thanks</p>