1

I'm having an issue plotting on gnuplot with my C program. When I compile it, the popen() function successfully opens up the gnuplot program, but once it's open, it does not receive the data from the fprintf stream. Here is the relevant function from my program:

void plot_data() {
    FILE* gnuplot = popen("wgnuplot.exe -persistent", "w");
    fprintf(gnuplot, "plot '-'\n");
    for(int j=0; j<DATA_ENTRIES; j++) fprintf(gnuplot, "%f %f %f\n", data[j].x, data[j].y, data[j].z);
    fprintf(gnuplot, "e\n");
    fflush(gnuplot);
}
Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Gucci
  • 11
  • 2
  • How do you know that it doesn't receive data? Some programs wait for closed stdin (so you need to call `fclose`) and won't do anything until that. – myaut Feb 02 '17 at 15:12
  • How do you know it doesn't receive it? – Eugene Sh. Feb 02 '17 at 15:12
  • 1
    @myaut According to [this](http://stackoverflow.com/questions/3521209/making-c-code-plot-a-graph-automatically) `fflush` should be sufficient. – Eugene Sh. Feb 02 '17 at 15:14

0 Answers0