I have two variables:
char charTime[] = "TIME";
char buf[] = "SOMETHINGELSE";
I want to check if these two are equal… using charTime == buf doesn’t work.
What should I use, and can someone explain why using == doesn’t work?
Would this action be different in C and C++?
C++ and C (remove
std::for C):But the true C++ way:
Using
==does not work because it tries to compare the addresses of the first character of each array (obviously, they do not equal). It won’t compare the content of both arrays.