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);
}
3
  • 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. Commented Feb 2, 2017 at 15:12
  • How do you know it doesn't receive it? Commented Feb 2, 2017 at 15:12
  • 1
    @myaut According to this fflush should be sufficient. Commented Feb 2, 2017 at 15:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.