I'm writing a code that will run through each bin in a histogram and check if there are any non zero bins. If there are, it throws out an error message. My issue is, I want it to skip a bin because this bin should not be empty, but check all the other bins.
Only thing is this is creating an infinite loop. Here's my code
Int_t y;
for (int i = 0; i <= 100; i++) {
y = hist - > GetBinContent(i)
if (i = 1) continue;
else if (y != 0) {
std: cout << * * * * * ERROR * * * * * << std: endl;
break;
}
}
What's happening is it evaluates it for i = 0, skips i = 1, and then hits i = 2 and just continually evaluates that over and over again. If I take out the "if (i=1) continue;" line then it works.
Any ideas?
Try this
i=1mean you assign1toi.=means assign and==mean comparing .In your code the value of
iwill always be1as you are usingi=1