条件跳转或移动取决于未初始化的值 - C valgrind
我收到这个错误: ==4024== 条件跳转或移动取决于未初始化的值 ==4024==在0x400D69:constructBoardSpaces(在/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]=' ';
}
}
}
}
无法弄清楚问题是什么。 谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定在进入该循环之前初始化了二维数组吗?否则我会说问题可能出在从数组读取的 if 语句中:
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: