0

program in c++ to compare two strings and return 0 if the two strings are equal and -1 is strings are unequal

23rd Jan 2018, 3:56 PM
Raj Zamal
Raj Zamal - avatar
2 Respostas
- 1
just do #include <string> short compare(const std::string &a, const std::string &b) { return (a == b) ? 0 : -1; } or #include <string> bool compare(const std::string &a, const std::string &b) { return (a == b); } or just a == b
23rd Jan 2018, 8:43 PM
Timon Paßlick
+ 7
Hint: Use compare() method from the string class.
23rd Jan 2018, 4:10 PM
Ipang