[英]error: invalid conversion from 'short unsigned int*' to 'short unsigned int'| (in c++)
I am new to programming and I have been trying to create a program that would solve any Sudoku puzzle. 我是编程新手,我一直在尝试创建一个可以解决数独难题的程序。 However, I've been getting a lot of errors, and in this one I just can't figure out what's wrong.
但是,我遇到了很多错误,而在这一错误中,我只是无法弄清楚出了什么问题。
This is the code where the error is: 这是错误所在的代码:
for (short o = indice;o>=divergencias[n_diver];o--){
N=historico[o];
P=tabela[N]; //Line 205
tabela[N]=0; //Line 206
}
indice -= divergencias[n_diver];
n_diver --;
}
And the errors, which happened on the lines marked with comments, are: 在标有注释的行上发生的错误是:
C:\(...)\main.cpp|205|error: invalid conversion from 'short unsigned int*' to 'short unsigned int'|
and 和
C:\(...)\main.cpp|206|error: incompatible types in assignment of 'int' to 'short unsigned int [9]'|
I've been searching for this error, and didn't find any satisfying answer to it. 我一直在寻找此错误,但没有找到令人满意的答案。 Moreover, the website in which I learn what I know about programming specifies that writing something like
b = billy [a+2];
而且,在我了解编程知识的网站上,指定编写
b = billy [a+2];
is valid. 已验证。 So I just can't understand what's wrong with this...
所以我只是不明白这是怎么回事...
It looks like tabela
is declared as short unsigned tabela[9][9]
. 看起来
tabela
被声明为short unsigned tabela[9][9]
。 In order to get an item of type unsigned short
from it you have to provide two indexes, not one. 为了从中获得
unsigned short
类型的项目,您必须提供两个索引,而不是一个。
On the other hand, if you are looking to get an entire sub-array from tabela
, the left side of the assignment needs to be compatible with a 1-D array of unsigned short
, for example, an unsigned short*
pointer. 另一方面,如果要从
tabela
获取整个子数组,则分配的左侧需要与unsigned short
的一维数组(例如, unsigned short*
指针)兼容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.