Thursday, 12 March 2015

Compare two strings without using 'strcmp'

main()
{
int i=0;
char s1[10],s2[10];
printf("Enter 2 strings\n");
scanf("%s%s",s1,s2);
while (s1[i]==s2[i] && s1[i]!='\0' && s2[i]!='\0')
i=i+1;
if ( s1[i]=='\0' && s2[i] =='\0')
printf("              equal");
else
printf("              not equal");
}