-strcmp() is the string function that are able to compare two string.
-It is predefined in string.h header file
Syntax-
strcmp(string1,string2)
-It return 1 if both string is different
-It return 0 if both string is equal.
program:
#include< iostream>
#include< string.h>
int main()
{
char ch1[20],ch2[20];
//input of string
cout<<"Enter first string"<< endl;
cin>>ch1;
cout<<"Enter second string"<< endl;
cin>>ch2;
if(strcmp(ch1,ch2))
cout<<"Not same";
else
cout<<"Same";
}
Enter first string
Mystring
Enter second string
Mystring
Same
Enter first string
Mystring
Enter second string
My
Not same