+ 5
How to show two strings equal in C++?
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`
+ 6
== operator for equality check
+ 2
strcmp function
+ 2
in string. h library