次のサンプル・プログラムは plot sin(x) させる、というものです。
| testcallgnuplot0.c |
/*
* testcallgnuplot0.c
*/
#include <stdio.h>
int main(void)
{
FILE *gp;
char buf[BUFSIZ];
gp = popen("gnuplot", "w");
fprintf(gp, "plot sin(x)\n");
fflush(gp);
/* 行入力を待つ --- Enterを打つまで待つ */
fgets(buf, sizeof(buf), stdin);
/* パイプを閉じる */
pclose(gp);
return 0;
}
|
| testcallgnuplot1.c |
/*
* testcallgnuplot1.c
*/
#include <stdio.h>
int main(void)
{
FILE *gp;
gp = popen("gnuplot -persist", "w");
fprintf(gp, "plot sin(x)\n");
pclose(gp);
return 0;
}
|