How to lunch this program by root in windows?


_ROOT Version:v5.34.38.win32.vc12
Platform: Not Provided
Compiler: Not Provided


I am really new in this and i don’t know how to open my file in root.If i pull my file to root,it just back me this.

Processing D:\necessary application\root\root\macros\test1.cpp…
Error: Function test1() is not defined in current scope (0)

and whatever i do,it just back me the same answer,i even don’t know why i can’t use the same sentence i find in other place ,because they use it in linux?
please help me,please

#include <iostream>
#include <fstream>
#include <cassert>
#include <string>
#include <cmath>
#include <TH1F> 
using namespace std;
void test()
{
	int i,y=0;
	double x=0.0,b=0.0,q,s,a[10000];
	TH1F*h=new TH1F("h","f",10000,-20.0,20.0);
    ifstream infile;
	infile.open("C:\\Users\\asus\\Desktop\\1bg.txt",ios::in);   
    assert(infile.is_open());

    double c,pi=3.14159265;
    while (!infile.eof())
    {
        infile >> c;
        a[y]=c;
        x=x+c;
        y=y+1;
		
    }
    q=x/y;
    for(i=0;i<y;i++)
    {
        b=b+(a[i]-q)*(a[i]-q);
    }
    s=sqrt(b/y);
    for(int k=;k<y;k++)
    {
    	h->Fill((exp(-(a[k]-q)*(a[k]-q)/(2*s*s))/(sqrt(2*pi)*s)));
	}
	h->Draw();
    infile.close();
}

Hi,

Rename your function test1() (the function name has to be the same than the macro file name…)

Cheers, Bertrand.

thankyou,but even i change the filename,the error is the same

So now, what is the file name and what is the function name?

well,it works,thankyou for help

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.