+ 5

How to show two strings equal in C++?

6th Mar 2018, 3:33 PM
Adarsh Singh
Adarsh Singh - avatar
5 odpowiedzi
+ 4
it's done just as you compare characters or numbers in c++. You just need to include one extra library <string> and then just as done below : #include <iostream> #include <string> using namespace std; int main() { string str1 = "string"; string str2 = "string"; if(str1 == str2) { cout<<"\n Strings are equal"; } else { cout<<"\n Strings are not equal"; } return 0; } `Edit : this comparison will be case sensitive`
6th Mar 2018, 3:40 PM
RZK 022
RZK 022 - avatar
+ 6
== operator for equality check
6th Mar 2018, 3:40 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 2
strcmp function
6th Mar 2018, 8:07 PM
Arun
+ 2
in string. h library
6th Mar 2018, 8:08 PM
Arun