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
:o
Printable View
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
:o
You can overload the == operator for your own string class, if you are so inclined.
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;