Write a function that can compare two strings in a manner that the function strcmp() does. Do not use strcmp() or any other library function.
#include<iostream>
using namespace std;
void compareTwoStrings (string str_inp1, string str_inp2) {
cout << "Enter the String 1: \n";
cin >> str_inp1;
cout << "Enter the String 2: \n";
cin >> str_inp2;
if (str_inp1 == str_inp2)
cout <<"Strings are equal." << endl;
else
cout <<"Strings are not equal." << endl;
}
int main() {
string str1;
string str2;
compareTwoStrings(str1, str2);
return 0;
}
Comments
Leave a comment