警告:数组赋值中指针和整数之间存在比较 charplayingfield[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,0x00,0x00,0x00,0x00}; 空投炸弹(空投) { int行=3,列=0; 对于(行;行>=0;行--) { for(column;column
字符串文本,如警告:数组赋值中指针和整数之间存在比较 charplayingfield[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,0x00,0x00,0x00,0x00}; 空投炸弹(空投) { int行=3,列=0; 对于(行;行>=0;行--) { for(column;column,c,pointers,C,Pointers,字符串文本,如“#”实际上是指向数组中第一个字符的指针 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, 0
“#”
实际上是指向数组中第一个字符的指针
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]="-";
}
}
}
}
正在将char
与char*
进行比较
我想你的意思是使用字符文字:
playingfield[row][column] == "#")
请注意从双引号“
更改为单引号”
当你编译这个时,你会遇到一个更糟糕的错误:看看
列
循环条件,它包括索引8
,它超出了数组的界限(它是数组中的第九个索引)。更改双引号中的字符串文字,如”$“
以单引号括起字符文字'$”
playingfield[row][column] == '#')