2
我需要通过管道将一个在我的主程序(普通C)中定义的变量传递给Gnuplot。我该怎么做?任何援助非常感谢。如何通过管道将C中定义的变量传递给Gnuplot?
感谢
PS:Ubuntu的LTS 12.04.3,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;
显示您的代码。你的C程序如何与'gnuplot'通信?通过传递变量是什么意思?你在用'popen'吗?怎么样?? –
@BasileStarynkevitch我正在写与我的论点有关的代码的一部分。 – Vesnog
@BasileStarynkevitch变量binsize在我的C源代码中定义,我想将它传递给Gnuplot并将其用于绘图目的。我注意到这部分,因为它遇到了问题,我也会选择直接使它可以由Gnuplot使用,而无需重命名它,如果可能的话。 – Vesnog