title: Use of FILE* in C to open command tools and feed data
body: <p>I've been researching ways of visualizing data and stumbled upon gnuplot. It seems great and really useful but I was trying to find a way of embedding it within the program itself instead of having to feel the data separately. I then stumbled on a stack overflow answer where the topic was discussed but they gloss over how certain things work since it didn't pertain to their question at the moment so I'm asking here:</p>
  <p>Their post <a href="https://stackoverflow.com/questions/29730732/piping-data-to-gnuplot-from-c">here</a>:</p>
  <p>So the code extract would be:</p>
  <pre><code>void gnuprint(FILE *gp, double x[], int N){     
       int i;
       fprintf(gp, &quot;plot '-' with lines\n&quot;);
  
       for (i=0; i&lt;N; i++){fprintf(gp, &quot;%g %g\n&quot;, x[i],WF[2*i+1]);}
       fflush(gp);
       fprintf(gp, &quot;e\n&quot;);                                                                
  }
  </code></pre>
  <p>From what I understand from the code they seem to have opened the gnuplot program as a file and piping in the information as if it was writing into a file. I simply fail to understand how one would initialize the gp pointer to hold the program open in such a state. Any help understanding how this is done would be appreciated. Thanks</p>