problem with IF statement
sdiguana
Posts: 11
So, im not sure why this doesnt work... any ideas? I have tried (if response ==0), ..=="0",.. !=0 or "0" and so on, the only time i step into the if statement is when i set !=, but then it goes off regardless of the Xbee's status.
Snippet:
Snippet:
while(1) { pause(1000); xbcmd("ATMY\r", response, 15, 200); // showing the XBee's IP-address print("IP Address = %s", response); print("cmd = ATAI\n"); // showing 0 if the connection was successful xbcmd("ATAI\r", response, 10, 20); // shows FF when scanning for a connection print("reply = %s", response); print(response); if (response != "FF") { print("entered IF Statement"); break; } }
Comments
It's standard C. You can't use relational operators to compare strings. Even StackOverflow says so. The relations operators work on the standard (sorry, not the word I want) variable types: int, char, bool, float, etc.
You need to use strcmp to compare strings in C.