func int gnuplotIspis(real[int] & h, real[int] & err, int noOfItems, string & title)
{
if( (noOfItems > err.n) || (noOfItems > h.n) )
{
cout << "Greska pri pozivu funkcije gnuplotIspis. "
<< "Broj elemenata za ispis suvise velik.\n";
cout << "Broj elemenata za ispis = "<< noOfItems << endl;
cout << "Dimenzija polja h = " << h.n << endl;
cout << "Dimenzija polja err = " << err.n << endl;
exit(-37);
}
{ // staviti u blok jer je to jedini način da se zatvori file
ofstream data("02348195data.gnuplot");
for(int i=0; i< noOfItems; ++i)
data << h[i]<< " "<<err[i]<< endl;
}
string ime=title+".gnu";
{
ofstream gnu(ime);
gnu << "set terminal postscript color"<<endl;
gnu << "set output \""<< title << ".ps\""<<endl;
gnu << "plot \'02348195data.gnuplot\' using 1:2 w l t \""+title+"\""<<endl;
} // ovdje file mora biti zatvoren da bi ga gnuplot mogao otvoriti
exec("gnuplot "+ime);
exec(" rm 02348195data.gnuplot");
return 1;
}