簡體   English   中英

錯誤:從'short unsigned int *'到'short unsigned int'的無效轉換| (在C ++中)

[英]error: invalid conversion from 'short unsigned int*' to 'short unsigned int'| (in c++)

我是編程新手,我一直在嘗試創建一個可以解決數獨難題的程序。 但是,我遇到了很多錯誤,而在這一錯誤中,我只是無法弄清楚出了什么問題。

這是錯誤所在的代碼:

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 --;
    }

在標有注釋的行上發生的錯誤是:

C:\(...)\main.cpp|205|error: invalid conversion from 'short unsigned int*' to 'short unsigned int'|

C:\(...)\main.cpp|206|error: incompatible types in assignment of 'int' to 'short unsigned int [9]'|

我一直在尋找此錯誤,但沒有找到令人滿意的答案。 而且,在我了解編程知識的網站上,指定編寫b = billy [a+2]; 已驗證。 所以我只是不明白這是怎么回事...

看起來tabela被聲明為short unsigned tabela[9][9] 為了從中獲得unsigned short類型的項目,您必須提供兩個索引,而不是一個。

另一方面,如果要從tabela獲取整個子數組,則分配的左側需要與unsigned short的一維數組(例如, unsigned short*指針)兼容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM