简体   繁体   English

错误:从'short unsigned int *'到'short unsigned int'的无效转换| (在C ++中)

[英]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.

相关问题 short int到unsigned int转换网络字节顺序C ++ - short int to unsigned int conversion network byte order C++ 将unsigned int转换为short unsigned int - Narrowing Conversion of unsigned int to short unsigned int C++ 容器类型面临从 map 转换等问题<long unsigned int, ..>到非标量类型 map<short unsigned int, ..></short></long> - C++ container types facing an issue like conversion from map<long unsigned int, ..> to non scalar type map<short unsigned int, ..> c++中signed int和unsigned short的比较 - Comparison of signed int and unsigned short in c++ unsigned int vs c ++中的unsigned short difference - unsigned int vs unsigned short difference in c++ 将 unsigned short * 转换为 unsigned int * - Cast unsigned short * to unsigned int * C ++错误:从&#39;unsigned int *&#39;到&#39;unsigned int&#39;的无效转换。 将数组元素设置为另一个数组元素的地址时 - C++ Error: Invalid conversion from 'unsigned int*' to 'unsigned int'. When setting array element to address of another array's element unsigned short int和unsigned int或unsigned short之间有什么区别? - What the difference between unsigned short int and unsigned int or unsigned short? C ++-从“ int”到“ unsigned char”的无效缩小转换 - C++ - Invalid narrowing conversion from “int” to “unsigned char” 如何将char *缓冲区转换为unsigned short int * bufferSh - c++ - How to convert char * buffer to unsigned short int * bufferSh
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM