int i; if(nCountedBars<=2) … if(nCountedBars>2){…} while(i>=2) << it gives warning here (possible use of uninitialized variable 'i')
If the first if is false and the second is also false, i is uninitialized. You are smarter than the compiler.
Hi, I am trying to put fractals on my chart with this code but on while(i>=2) statement, it says --> possible use of uninitialized variable 'i'
why is 'i' not getting initialized when its getting initialized in if statement..
..regards.
Simply make the
int i
to be a global variable.
Simply make the
int i
to be a global variable.
Why?
Apart from anything else it is bad practice to declare variables globalscope when there is no need to.
Did you see my earlier post?
Please do it.
Actually
will fix the warning but again as William said, when both ifs are false you will not enter in the while and your fractal will not be displayed.
You have to change your logic.
Be it any value it will be less than or equal to 2 or greater than 2. Out of three any one will be correct. So I think logic is alright here. What say?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I am trying to put fractals on my chart with this code but on while(i>=2) statement, it says --> possible use of uninitialized variable 'i'
why is 'i' not getting initialized when its getting initialized in if statement..
..regards.