I have stumbled on an interesting thing related to C-style strings.
Suppose I have this code:
const char* str = "a";
const char* str1 = "a";
if (str == str1)
cout <<"MAGIC HAPPENED!str="<<str<<", str1="<<str1 << endl;
If I understand correctly, if statement in this particular case should compare 2 pointers(since it is const char *, not the actual char of 1 byte), therefore the result should be false (since str and str1 are 2 different variables). Yet somehow I am getting result true - I see the output.
Any ideas why? :-)
NOTE: I am testing on Windows, with Qt's MINGW 11.2.0 compiler. And I am terribly sorry if this question was already answered.