strcmp()

Prototype: int strcmp (const char *string1, const char *string2);
Header File: string.h (C) or cstring (C++)
Explanation: Tests the strings for equality. Returns a negative number if string1 is less than string2, returns zero if the two strings are equal, and returns a positive number is string1 is greater than string2



//Example reads in two strings (w/out spaces) and compares them for equality
#include <cstring>
#include <iostream>

using namespace std;

int main()
{
    char *str1=new char[20];
    char *str2=new char[20];
    cin>>str1;
    cin>>str2;
    if(!strcmp(str1, str2)
    {
        cout<<"Strings are equal!";
    }
}
Other Functions