I am trying to plot graphs using GNUPLOT
which is a command line interface. But I need to integrate it in c program, so that if program gets executed, graph is plotted. This can be done by using popen
command. I have made a code where I am doing popen("gnuplot","r")
so now when I execute the program, gnuplot starts. But I need to send multiple commands like popen("sin(x)","r")
after popen("gnuplot","r")
so that a sin graph is plotted when I execute the code. But i dont know how to pass multiple commands.Please tell me how can I pass multiple commands using popen
.Please help thanks?
Here is the code which I am using to send single command:
#include <stdio.h>
int main()
{
FILE *fp;
int status;
fp = popen("gnuplot","r");
pclose(fp);
return 0;
}