0
char* lastfeedbuffer[3];
void lastfeed_receive(){
  while(Serial.available() >= LASTFEED_LEN ){
    char c = Serial.read();
    if (c == LASTFEED_HEAD){
      for (int i = 0; i < LASTFEED_LEN - 1; i++){
        lastfeedbuffer[i] = Serial.read();
      } 
    }
  }
  Serial.println(lastfeedbuffer);
  if (lastfeedbuffer == "00"){
    Serial.println("asdf");
  }
}

I don't understand why the following code is not printing the asdf. the Serial.println(lastfeedbuffer) prints 00, which means it should go into the loop any ideas why it doesn't?

1
  • 2
    lastfeedbuffer and "00" are not of compatible types: the first is of type array of 3 pointer to char; the second is of type array of char. Increase the warning level of your compiler and MIND THE WARNINGS. Commented Apr 28, 2011 at 22:07

1 Answer 1

3

Use strcmp(lastfeedbuffer, "00") == 0 - What you're currently doing is to compare two unrelated pointers.

Also, I believe you have char lastfeedbuffer[3]; not char* lastfeedbuffer[3]; in your actual code?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.