Compare two strings - C++ Program

Q. Write a C++ program to compare two strings.


Following program is comparing two strings using strcmp() library function. This function is used to compare the two strings with each other.

using namespace std;
int main()
        char str1[100], str2[100];
        cout<<"\n Enter First String : ";
        cout<<"\n Enter Second String : ";
        if(strcmp(str1, str2)==0)  //strcmp() is a library function, used to compare the two strings.
                cout<<"\n Strings are Equal!!!";
                cout<<"\n Strings are Not Equal!!!";
        return 0;


compare string 1

compare string 2