条件跳转或移动取决于未初始化的值 - C valgrind

标签 c valgrind

我遇到了这个错误: ==4024== 条件跳转或移动取决于未初始化的值 ==4024== at 0x400D69: constructBoardSpaces (in/a/fr-01/vol/home/stud/roniy02/oop/Ex3/Play)

函数是:

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]=' ';
                }
        }
    }
}

想不通是什么问题。 谢谢

最佳答案

你确定你在进入那个循环之前初始化了二维数组吗?否则我会说问题可能出在您从数组中读取的 if 语句中:

if((array[i][j])!='X'&&(array[i][j]!='O'))

关于条件跳转或移动取决于未初始化的值 - C valgrind,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7105004/

相关文章:

c - 了解二维数组中字符串的寻址

c - valgrind 显示内存泄漏。我该如何阻止泄漏?

c - 来自 getaddrinfo() 的 4 错误的无效读取大小

c - 传递 NULL 时 strdup 转储核心

c - 为什么 wszName 不正确?

c - 64 位数字和 (C) [随意编辑我的英文]

c - 两个格式说明符但只有一个参数

c++ - CPP中的Valgrind和内存泄漏: “Conditional jump or move depends on uninitialised values”

c - 使用 realloc 的程序在 Valgrind 中表现不同

c - 多个 valgrind 错误 : Conditional jump or move depends on uninitialised value(s)