I am trying to plot a real-time graph in gnuplot from my C ++ program. I installed gnuplot 4.6 and can open gnuplot.exe and the graph chart. But I can not open the application through the channels. This is the code I used.
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE* gp;
char *path = "C:\Program Files\gnuplot\bin\wgnuplot";
#ifdef WIN32
gp = _popen("gnuplot -persist", "w");
#else
gp = _popen(path, "w");
#endif
if (gp == NULL)
return -1;
fprintf(gp, "set isosample 100\n");
fprintf(gp, "min=-1\n");
fprintf(gp, "max=1\n");
fprintf(gp, "pi=3.141592\n");
fprintf(gp, "set hidden3d\n");
fprintf(gp, "set pm3d\n");
fprintf(gp, "set contour\n");
fprintf(gp, "splot [min:max] [min:max] x*x+2*y*y-0.3*cos(3*pi*x)-0.4*cos(4*pi*y)+0.7\n");
fprintf(gp, "pause -1\n");
return 0;
}
I set the environment variables and I got the following error. c: program \ is not recognized as an internal or external command and operating program or batch file.
I tried to run exe with the same path. But he does not open. This is because of the maximum line length that can be specified on the cmd command line.
Please give your valuable advice.
thank
source
share