this program is used to check weather two entered strings are same or not.it two strings are equal then it will return that entered two stings are same and if two strings are not equal then it will return that from which character two strings differ.Further run this program to your computer for more understanding.
Program:
#include<stdio.h>
#include<conio.h>
main()
{
int i=0,c=0;
char str1[300],str2[300];
clrscr();
printf("Enter string 1: ");
gets(str1);
printf("\nEnter string 2: ");
gets(str2);
while((str1[i]!='\0')||(str2[i]!='\0'))
{
if(str1[i]==str2[i])
{
i++;
}
else
{
printf("\nEntered two string differs from %d character",i);
goto END;
}
}
printf("\nThese Two strings are same");
END:
getch();
}
Program:
#include<stdio.h>
#include<conio.h>
main()
{
int i=0,c=0;
char str1[300],str2[300];
clrscr();
printf("Enter string 1: ");
gets(str1);
printf("\nEnter string 2: ");
gets(str2);
while((str1[i]!='\0')||(str2[i]!='\0'))
{
if(str1[i]==str2[i])
{
i++;
}
else
{
printf("\nEntered two string differs from %d character",i);
goto END;
}
}
printf("\nThese Two strings are same");
END:
getch();
}