Modify a path for each loop of the function "for"

Hello,

I want to save several histograms in a folder that I draw in a “for” loop. The histograms plot well but when I try to save them using print, the histogram from the previous loop erases the histogram from the next loop. In the end I have more than the histograms from my last one in my files. I don’t know how to modify my path for each loop made.

for (int j = 300; j <= 305; j++ )

{
… I created a canvas and insert the data into hist …

hist->Draw();
c1->Print("/home/dupuy/Documents/code_dupuy/Exercices/Image/1.png");
}

i want to create a path using the j.

c1->Print(TString::Format("/home/dupuy/Documents/code_dupuy/Exercices/Image/%d.png", j));

Hi,
try

c1->Print(Form("/home/dupuy/Documents/code_dupuy/Exercices/Image/%03i.png", j));

Thank you so much, it works !!