Hi all, I would like to include the window class name into my if statement but I always get error. It is the issue of char and string but I tried several times still can't make it. Does anyone know how to solve this?
1. Single quotes contain one literal character. Button is not a character. It should be an array or characters.
Double quotes hold literal string: "Button"
2. The class_name is a pointer. String literal is accessed via a pointer. Two pointers are equal only if the point to same byte.
If you want to compare C-strings pointed to by pointers, then you have to C's functions.
If you want to use C++, then use std::string: ( std::string(class_name) == "Button" )
One of them is booloperator== (const string&, constchar*);
Unnamed std::string object on the left and literal C-string constant on the right (the "Button") match that operator== and the operator computes whether they are equal.