c语言简单编程

Compare string1 and string2
• Input the number to check
• Input the string1
• Input the string2
• Compare the string1 and string2图片说明图片说明图片说明

 #include<stdio.h>
#include<string.h>
void main ()
{
    char str1[50],str2[50];
    int n,i,count,len1,len2;
    printf("Input the number to check : ");
    scanf("%d",&n);
    printf("Input the string1 : ");
    scanf("%s",str1);
    printf("Input the string2 : ");
    scanf("%s",str2);
    len1=strlen(str1);
    len2=strlen(str2);
    for(i=0,count=0; i<n; i++)
    {
        if( str1[i]==0 || str2[i]==0 ) break;
        if(str1[i]==str2[i]) count++;
        else break;
    }

    if(i==count && i==n) printf("equal %d character\n",count);
    else if(len1==len2 && i==count && i<=n && i==len1) printf("equal\n");
    else printf("not equal\n");
}