Program to compare two string without using strcmp in c language.

#include<stdio.h>
#include<string.h>
Void main()
{
      char a[20],b[20],i,l1,l2;
       printf(“Enter the first string”);
      gets(a);
      printf(“Enter the second string”);
      gets(b);
      l1=strlen(a);
      l2=strlen(b);
      if(l1==l2)
      {
          for(i=0;i<=l1-1;i++)
          {
              if(a[i]!=b[i])
                  break;
          }
          if(i==l1)
             printf(“string matched”);
          else
             printf(“string not matched”);
        }
      else
         printf(“string not matched”);
      getch();
}
      

4 thoughts on “Program to compare two string without using strcmp in c language.

Leave a Reply

Your email address will not be published.