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]; is valid. So I just can’t understand what’s wrong with this…
It looks like
tabelais declared asshort unsigned tabela[9][9]. In order to get an item of typeunsigned shortfrom it you have to provide two indexes, not one.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 ofunsigned short, for example, anunsigned short*pointer.