我需要通过管道将主程序(纯 C)中定义的变量传递给 Gnuplot。我怎样才能这样做呢?非常感谢任何帮助。
谢谢
PS:Ubuntu 12.04.3 LTS,GCC 4.6.3
代码:
FILE *pipe = popen("gnuplot -persist","w");
//fprintf(pipe, "bin_width = binsize; ");
fprintf(pipe, "load 'Q3.gnu' \n");
close(pipe);
编辑:我已经解决了我自己的问题,很抱歉占用您的时间。解决办法是:
FILE *pipe = popen("gnuplot -persist","w");
fprintf(pipe, "binsize = %f;", (float)binsize);
fprintf(pipe, "load 'Q3.gnu' \n");
close(pipe);
return 0;
最佳答案
我无法给您确切的答复,但 gnuplot_i 接口(interface)使用管道机制与 gnuplot session 进行通信。看起来非常接近你的要求。相信您可以在项目首页( http://ndevilla.free.fr/gnuplot/ )找到有用的信息。
关于c - 如何通过管道将 C 中定义的变量传递给 Gnuplot?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20734949/