#define MAXBUF 100000 #define MAXVAL 10 void graph(char *filename) { FILE *fp; char buf[256]; double x[MAXBUF],y[MAXBUF]; int i; fp = fopen(filename, "r"); if (!fp) { fprintf(stderr,"cannot open %s\n",filename); } i=0; while (1) { if (fgets(buf, sizeof(buf), fp)==NULL) break; if (buf[0] == '#' || buf[0] == '\n') continue; sscanf(buf,"%lf %lf", &x[i], &y[i]); i++; } TGraph *gr = new TGraph(i, x, y); gr->SetTitle(""); gr->SetName("gr"); gr->SetMarkerColor(kBlue); gr->SetMarkerStyle(20); gr->SetMarkerSize(0.7); gr->Draw("ap"); }