strcmp fucntion is used to compare two strings.if str1 is equal to str2 it returns 0,if str1 is greater then str2 it returns greater then 0 and if str2 is greater then str1 it returns less then 0.
Example:
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char name[50]="errorless-c.blogspot.com";
char discription[50]="learn c programming";
char name2[50]="errorless-c.blogspot.com";
clrscr();
printf("%d because name>discription",strcmp(name,discription));
printf("\n%d beacuse name=name2",strcmp(name,name2));
printf("\n%d because discription<name",strcmp(discription,name));
getch();
}
Example:
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char name[50]="errorless-c.blogspot.com";
char discription[50]="learn c programming";
char name2[50]="errorless-c.blogspot.com";
clrscr();
printf("%d because name>discription",strcmp(name,discription));
printf("\n%d beacuse name=name2",strcmp(name,name2));
printf("\n%d because discription<name",strcmp(discription,name));
getch();
}