I want to compare a user defined string array with a string constant using the '==' operator. Is this possible. for example
if(somestringarray == "Hello") then print "Good Morning"
is there another way to do this? thanks
I want to compare a user defined string array with a string constant using the '==' operator. Is this possible. for example
if(somestringarray == "Hello") then print "Good Morning"
is there another way to do this? thanks
You can overload the == operator for your own string class, if you are so inclined.
FAQ
"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.
"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.
Or make somestringarray a string variable. Eg:
Code:#include <string> using namespace std; [..] char stringarray[] = "Hello"; string somestringarray = stringarray; if (somestringarray == "Hello") cout << "Good morning" << endl;