Answer to Question #164744 in C++ for chetana

Question #164744

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.


1
Expert's answer
2021-02-18T14:37:52-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment