Ululì Ululà
2021-04-22 14:45:42 UTC
I state that I am a beginner with C and C ++ and my English is bad.
I have to draw an f (x) on the Cartesian plane using C ++ and Gnuplot.
I have:
Windows 7 (64 bit)
DEVC ++ Embarcadero compiler Version 6.3
Gnuplot Version 5.2 patchlevel 8
I call Gnuplot from a DevC ++ program by passing it the string "Frase"
that contains the actions that Gnuplot will have to perform. When I
start the program the graph of f(x) does not respect the information
provided to Gnuplot with the string "Frase": for example the command
"unset key" it is not respected as well as the "set grid" command.
Why?
Below is the listing of my test program and I thank in advance whoever
succeeds to help me.
This is my program:
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main(void) {
char Frase[300]="plot [1:4] x*x+1;set grid;unset key;set title
'f(x)';set xlabel 'X (m)';set ylabel 'Y (m)';set border \n";
int Funzione;
FILE * iFile, * oFile;
Funzione=4;
while (Funzione>0)
{
system("cls");
printf("Inserisci Funzione (0=EXIT) : ");
scanf("%d", &Funzione);
if (Funzione>0)
{
oFile = fopen("comando_A.txt", "wt");
fprintf(oFile,Frase);
fprintf(oFile,"pause -1");
fclose(oFile);
system("gnuplot comando_A.txt");
}
}
return(0);
}
I have to draw an f (x) on the Cartesian plane using C ++ and Gnuplot.
I have:
Windows 7 (64 bit)
DEVC ++ Embarcadero compiler Version 6.3
Gnuplot Version 5.2 patchlevel 8
I call Gnuplot from a DevC ++ program by passing it the string "Frase"
that contains the actions that Gnuplot will have to perform. When I
start the program the graph of f(x) does not respect the information
provided to Gnuplot with the string "Frase": for example the command
"unset key" it is not respected as well as the "set grid" command.
Why?
Below is the listing of my test program and I thank in advance whoever
succeeds to help me.
This is my program:
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main(void) {
char Frase[300]="plot [1:4] x*x+1;set grid;unset key;set title
'f(x)';set xlabel 'X (m)';set ylabel 'Y (m)';set border \n";
int Funzione;
FILE * iFile, * oFile;
Funzione=4;
while (Funzione>0)
{
system("cls");
printf("Inserisci Funzione (0=EXIT) : ");
scanf("%d", &Funzione);
if (Funzione>0)
{
oFile = fopen("comando_A.txt", "wt");
fprintf(oFile,Frase);
fprintf(oFile,"pause -1");
fclose(oFile);
system("gnuplot comando_A.txt");
}
}
return(0);
}