char playingfield[4][8] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
void dropbomb(void)
{
int row = 3 , column = 0;
for(row;row>=0;row--)
{
for(column; column<=8;column++)
{
if(playingfield[row][column] == "#")
{
playingfield[row][column] = "$";
OledSetCursor(column,row);
OledPutChar(playingfield[row][column]);
}
else if(playingfield[row][column] =="$")
{
playingfield[row][column] = " ";
OledSetCursor(column,row);
OledPutChar(playingfield[row][column]);
if(row<3)
{if(playingfield[row+1][column]=="$")
playingfield[row+1][column]="*";
else if(playingfield[row+1][column]=="&")
playingfield[row+1][column]=".";
else if (playingfield[row+1][column]=="'")
playingfield[row+1][column]=",";
}
}
else if(playingfield[row][column]==",")
stage = "finished";
else if(playingfield[row][column]=="%")
{
playingfield[row][column] = "&";
OledSetCursor(column,row);
OledPutChar(playingfield[row][column]);
}
else if (playingfield[row][column]=="&")
{
playingfield[row][column] = " ";
OledSetCursor(column,row);
OledPutChar(playingfield[row][column]);
if(row<3)
{if(playingfield[row+1][column]=="$")
playingfield[row+1][column]="+";
else if(playingfield[row+1][column]=="&")
playingfield[row+1][column]="/";
else if (playingfield[row+1][column]=="'")
playingfield[row+1][column]="-";
}
}
else if (playingfield [row][column]=="*")
{
playingfield[row][column] = "$";
OledSetCursor(column,row);
OledPutChar(playingfield[row][column]);
if(row<3)
{if(playingfield[row+1][column]=="$")
playingfield[row+1][column]="*";
else if(playingfield[row+1][column]=="&")
playingfield[row+1][column]=".";
else if (playingfield[row+1][column]=="'")
playingfield[row+1][column]=",";
}
}
else if (playingfield[row][column]=="+")
{
playingfield[row][column] = "&";
OledSetCursor(column,row);
OledPutChar(playingfield[row][column]);
if(row<3)
{if(playingfield[row+1][column]=="$")
playingfield[row+1][column]="*";
else if(playingfield[row+1][column]=="&")
playingfield[row+1][column]=".";
else if (playingfield[row+1][column]=="'")
playingfield[row+1][column]=",";
}
}
else if(playingfield[row][column] == "-")
{
score=score+1;
playingfield[row][column] == "'";
}
else if (playingfield[row][column] == ".")
{
playingfield[row][column] = "$";
OledSetCursor(column,row);
OledPutChar(playingfield[row][column]);
if(row<3)
{
if(playingfield[row+1][column]=="$")
playingfield[row+1][column]="+";
else if(playingfield[row+1][column]=="&")
playingfield[row+1][column]="/";
else if (playingfield[row+1][column]=="'")
playingfield[row+1][column]="-";
}
}
else if (playingfield[row][column] == "/")
{
playingfield[row][column] = "&";
OledSetCursor(column,row);
OledPutChar(playingfield[row][column]);
if(row<3)
{
if(playingfield[row+1][column]=="$")
playingfield[row+1][column]="+";
else if(playingfield[row+1][column]=="&")
playingfield[row+1][column]="/";
else if (playingfield[row+1][column]=="'")
playingfield[row+1][column]="-";
}
}
}
}
我试图逐个浏览这个数组中的单元格。但是,对于涉及“playfield [row] [column]”的任何地方,它告诉我指针和整数之间的比较。另外一个警告说,Assignment使指针在没有强制转换的情况下从指针生成整数。
答案 0 :(得分:2)
字符串文字,如"#"
实际上是指向数组中第一个字符的指针。你在做什么,例如。
playingfield[row][column] == "#")
将char
与char *
进行比较。
我认为您打算使用字符文字:
playingfield[row][column] == '#')
请注意从双引号"
到单引号'
的更改。
当你进行编译时,你会遇到更糟糕的错误:查看column
循环条件,包含索引8
,这超出了界限数组(它是数组中的第九个索引)。
答案 1 :(得分:0)
将双引号(例如"$"
)中的字符串文字更改为单引号'$'
中的字符文字。