KodeGod.com

091. Write a program to compare two strings in C language

#include<stdio.h>
#include<conio.h>  
#include<process.h>
main()
{
	int i;
	char *s1,*s2;
	clrscr();
	printf("Enter the string 1....");
	scanf("%s",s1);
	printf("Enter the string 2....");
	scanf("%s",s2);

	for(i=0;s1[i]!='\0';i++)
	{
		 if(s1[i]!=s2[i])
			{
				if(s1[i]>s2[i])
					printf("\nString 1 is greater...");
				else
					printf("\nString 2 is greater...");
				getch();
				exit(0);
			}
	}
	printf("String are equal....");
	getch();
}