I'm using HTTPClient to grab a text file off a web server that is just a simple string as the contents. I'm then saving it to a variable so I can do something when it's a certain value.
Problem is, even when the value is what i want, the code things it's not. it's been years since I did any C++ and I'm not just following where I've failed.
txt is a HTTPText object, and lastState is a const char *
lastState = txt.gets();
printf("Got last state as: %s, %d \r\n", lastState, strlen(lastState));
if (lastState == "closed") {
printf("looks like closed \r\n");
} else {
printf("not closed \r\n");
}
}
even when it prints "closed" and a length of 6, the test in the if statement fails. I've also tried strcmp and it also fails the test. If i comment out the gets() and set it to closed manually, the test passes.
what am i doing wrong?
I'm using HTTPClient to grab a text file off a web server that is just a simple string as the contents. I'm then saving it to a variable so I can do something when it's a certain value.
Problem is, even when the value is what i want, the code things it's not. it's been years since I did any C++ and I'm not just following where I've failed.
txt is a HTTPText object, and lastState is a const char *
lastState = txt.gets(); printf("Got last state as: %s, %d \r\n", lastState, strlen(lastState)); if (lastState == "closed") { printf("looks like closed \r\n"); } else { printf("not closed \r\n"); } }
even when it prints "closed" and a length of 6, the test in the if statement fails. I've also tried strcmp and it also fails the test. If i comment out the gets() and set it to closed manually, the test passes. what am i doing wrong?