No, you are comparing the values ββof pointers (i.e.: addresses), not their contents. This code is not invalid, it probably does not do what you expect.
In C ++, you should avoid const char * and go to std::string :
#include <string> std::string t1("test1"); std::string t2("test2"); if (t1 == t2) { /* ... */ }
source share