Error: Function fill_graph(n,x,y,ex,ey,2) is not defined in current scope

Hi!
I’m new to C++ and ROOT (but not to programing (python)). I’m trying to create a function to fill a TGraphErrors, but I get the following error.

Processing C:\Users\acgc9\Desktop\CorrientesDeFuga.c...
Warning: Automatic variable i is allocated C:\Users\acgc9\Desktop\CorrientesDeFuga.c(26)
Error: Function fill_graph(n,x,y,ex,ey,2) is not defined in current scope  C:\Users\acgc9\Desktop\CorrientesDeFuga.c(30)
*** Interpreter error recovered ***

Here is the code:

/* Funtions declaration */

TGraphErrors fill_graph(Int_t n, Double_t x, Double_t y, Double_t ex, Double_t ey, Int_t index);

void CorrientesDeFuga() //main
{
	
	const Int_t n = 6;
	
	Double_t x[n] = {10, 20, 30, 40, 50, 60};
	Double_t y[n] = {10, 20, 30, 40, 50, 60};
	
	Double_t ex[n] = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1};
	Double_t ey[n] = {1, 1, 1, 1, 1, 1};
	
	TCanvas* c1 = new TCanvas("c1", "test", 640, 480);
	TMultiGraph* mg = new TMultiGraph();

	
	TGraphErrors* gr = new TGraphErrors(n, x, y, ex, ey);	
	gr -> SetMarkerStyle(1);
	gr -> SetMarkerColor(1);
	gr -> SetLineColor(1);
	mg -> Add(gr);
	
	for (i=0; i<n+1;++i)
	{
		y[i] = 2*y[i];
	}
	
	TGraphErrors* gr1 = fill_graph(n, x, y, ex, ey, 2);
	mg -> Add(gr1);
	
	mg -> Draw("ap");

	
}


TGraphErrors fill_graph(Int_t n, Double_t x, Double_t y, Double_t ex, Double_t ey, Int_t index)
{
	TGraphErrors* graph = new TGraphErrors(n, x, y, ex, ey);
	
	graph -> SetMarkerStyle(1);
	graph -> SetMarkerStyle(1);
	graph -> SetMarkerColor(index);
	
	return graph;
}

Thanks!

ROOT Version: 5.34/38
Platform: Windows 11
Compiler: CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010


TGraphErrors *fill_graph(Int_t n, Double_t *x, Double_t *y, Double_t *ex, Double_t *ey, Int_t index)

for (Int_t i = 0; i < n; i++)