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