strcmp() function in string Data structure by R4R Team

-strcmp() is the string function that are able to compare two string.
-It is predefine 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< stdio.h>
#include< string.h>
int main()
{
char ch1[20],ch2[20];
//input of string
printf("Enter first string\n");
scanf("%s",&ch1);
printf("Enter second string\n");
scanf("%s",&ch2);
if(strcmp(ch1,ch2))
printf("Not same");
else
printf("Same");
}


output-

Enter first string
Mystring
Enter second string
Mystring
Same

Enter first string
Mystring
Enter second string
My
Not same




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!