I am having a problem compiling fifteen.c. When I try to compile, I get an error in the move function saying:
fifteen.c:225:27: error: expected expression
coord_t = {i, j};
^
fifteen.c:229:27: error: expected expression
coord_z = {i, j};
^
A selection of my code from the move function is below. Note that I use a zero to represent the blank:
bool move(int tile)
{
// define coordinate variables: (row#, column#)
int coord_t[2];
int coord_z[2];
// find coordinates of tile and blank(i.e. zero)
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
if (board[i][j] == tile)
{
coord_t = {i, j};
}
if (board[i][j] == 0)
{
coord_z = {i, j};
}
}
}
Beyond the two error messages displayed above, I also get a third error message from some code later on (in the Won function) but I believe that's a separate issue. If it is a separate issue, please ignore it (or even edit it out or tell me to). I mention it just in case it is not a separate issue. Here's the third error message:
fifteen.c:266:24: error: comparison between pointer and integer ('int *' and 'int')
[-Werror]
if (!(board[i] == i))
~~~~~~~~ ^ ~
Here's the code relevant to the third error message:
for (int i = 0; i < d; i++)
{
if (!(board[i] == i))
{
return false;
}
return true;
What I've done: I've looked through a bunch of the move function questions on here but most seem to be taking a different approach and are not concerned with compiling errors. I looked through some of the Expected Expression error questions, but those seem to be caused by other issues (e.g. mismatched braces or repeated declarations of the same loop variable) different from whatever the issue is here.