Friday, November 24, 2017

Check two string weather they are same or not

///Check 2 string weather they are same or not
#include<stdio.h>
void main()
{
    int i,light=0;
    char s1[100],s2[100];
    gets(s1);///we
    gets(s2);///are
    if(strlen(s1)!=strlen(s2))
        printf("not same \n");
    else
    {
        for(i=0;s1[i]!=NULL;i++)
        {
            if(s1[i]!=s2[i])
            {
                light=1;
                break;
            }
        }
        if(light==1) printf("not same");
        else if(light==0)printf("same");
    }
}

No comments:

Post a Comment