possible use of uninitialized variable in array

Peter Zyler  

I'm hoping someone can help. This array was fine but all of a sudden I get this warning: possible use of uninitialized variable 'candles'. Not sure why the error.

int getPattern()
    if(Bars < 4) {

    int candles[4];

    for(int i=0; i<4; i++) {
        candles[i]  = candleType(i+1);

        if(0 == candles[i]) {
    if(candles[0] == candles[1] && candles[1] != candles[2] && candles[2] == candles[3]) {

Keith Watford  

You get the warning because you do not initialize the array.

The array elements are given values but within the for loop. The compiler cannot detect this so it issues the warning.

William Roeder  
Peter Zyler: but is that correct?

Yes, because you initialized it in the for loop.