Comparing two strings
Program
#include<stdio.h>
void main()
{
char str1[81],
str2[82];
int k, flag = 0;
printf("\nEnter
The First String : ");
scanf("%s",
str1);
printf("\n Enter
The Second String : ");
scanf("%s",
str2);
printf("\nProcessing
The Strings : ");
for(k = 0; str1[k] !=
'\0' && str2[k] != '\0'; k++)
{
if(str1[k] !=
str2[k])
{
flag = 0; break;
}
else
flag = 1;
}
if(flag == 1)
printf("\nStrings
Are Equal.");
else
printf("\nStrings
Are Not Equal.");
}
No comments:
Post a Comment