1

I got this error: ==4024== Conditional jump or move depends on uninitialised value(s) ==4024== at 0x400D69: constructBoardSpaces (in /a/fr-01/vol/home/stud/roniy02/oop/Ex3/Play)

and the function is:

static void constructBoardSpaces(char** array,int rows,int cols)
{
    int i=0,j=0;
    for (i = 0; i < rows; ++i)
    {
        for (j = 0; j < cols; ++j)
        {
            if((array[i][j])!='X'&&(array[i][j]!='O'))
                {
                array[i][j]=' ';
                }
        }
    }
}

can't figure out what is the problem. Thanks

fgfjhgrjr erjhm
  • 325
  • 1
  • 10
  • 24
  • Sounds familiar: http://stackoverflow.com/questions/7089892/conditional-jump-or-move-depends-on-uninitialised-values/7089919#7089919 – MByD Aug 18 '11 at 09:20
  • 1
    If you compile with the `-g` flag, then Valgrind will be able to tell you the precise line number of the code that has the problem. – caf Aug 18 '11 at 09:26

1 Answers1

1

are you sure you initialized the two dimensional array before you enter that loop? Otherwise I would say the problem is probably in the if statement where you read from the array:

if((array[i][j])!='X'&&(array[i][j]!='O'))
Markus Pilman
  • 3,104
  • 3
  • 22
  • 31
  • 2
    @fgfjhgrjr erjhm : When you ask a question and manage to get it solved, do try to post the answer/solution. Its not clear in this case, what exactly was the problem and what fixed it. – goldenmean Aug 18 '11 at 10:05
  • Request you to accept the answer if it solved your problem. This will help other readers. – Groovy Aug 18 '11 at 20:03