C Program to Compare Strings without Using String Functions

This is the C program to compare strings without using predefined string functions
[cc lang=”c”]
#include
char string1[100],string2[100];
int flag=1,len1=0,len2=0;
main()
{
int res;
printf(“Enter String-1n”);
gets(string1);
printf(“Enter String-2n”);
gets(string2);
while(string1[len1]!=’’){len1++;}
while(string2[len2]!=’’){len2++;}
res=compare(string1,string2);
if (res==-1||res==1) process(res);
else if(flag==len1&&flag==len2) process(0); else if(flag==len1&&flagcomp2) process(1);
else if(comp1len2) len=len2; else len=len1;
for(j=1;jb[j]) process(1); else if(a[j]

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *