1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| #include <stdio.h>
#include <stdlib.h>
int main(void)
{
int ret = EXIT_FAILURE;
char const *gnuname = "simple.1.gnu";
FILE *f = fopen(gnuname, "w");
printf (" main 1 \n");
if (f != NULL)
{
printf (" main 2 \n");
/*
* Write the control script for GNUplot
*/
fprintf(f, "# set terminal png transparent nocrop "
"enhanced font arial 8 size 420,320\n");
fprintf(f, "# set output 'simple.1.png'\n");
fprintf(f, "set key inside left top vertical Right "
"noreverse enhanced autotitles box "
"linetype -1 linewidth 1.000\n");
fprintf(f, "set samples 50, 50\n");
fprintf(f, "plot [-10:10] sin(x),atan(x),cos(atan(x))\n");
printf (" main 3 \n");
/*
* Run GNUplot on the control script (for Windows)
*/
{
char command[300];
printf (" main 4 \n");
const char *gnupath = "\"C:\\Program Files\\gnuplot\\bin\\wgnuplot.exe\"";
printf (" main 5 \n");
sprintf(command, "start %s %s", gnupath, gnuname);
printf (" main 5.1 \n");
printf("Executing %s...\n", command);
printf (" main 5.2 \n");
fclose(f);
printf (" main 5.3 \n");
FILE *f = fopen(gnuname, "w");
printf (" main 5.4 \n");
system(command);
printf (" main 6 \n");
}
fclose(f);
ret = EXIT_SUCCESS;
}
else
{
fprintf(stderr, "Could not create %s.\n", gnuname);
}
system("PAUSE");
return ret;
} |
Partager