|
char test1[3]={'O','K','A'};
char test2[3]={'O','K','B'};
char test3[3]={'O','K','C'};
char test4[3]={'O','K','D'};
void getData() {
int a=5;
int i=0,x=0,y=0,z=0,f=0,w=0;
if ( radio.available() )//如果通道裡有資料
{
radio.read( &dataReceived, sizeof(dataReceived) );//讀取資料
newData = true;
for(i=0;i<a;i++)
{
if(dataReceived[i] == test1[i])//比對回傳值
{
w++;
}
if(dataReceived[i] == test2[i])
{
x++;
}
if(dataReceived[i] == test3[i])
{
y++;
}
if(dataReceived[i] == test4[i])
{
z++;
}
}
//////////////////
當if(dataReceived[i] == test1[i])
{
w++;
}時 w的數值會是5
但走其他路徑時x,y,z出來的值都是3?
|
|