C Programming
#include
#include
int compstr(char a[],char b[]);
void main()
{
clrscr();
char str1[50],str2[50];
int x;
printf("Enter first string:");
gets(str1);
printf("Enter second string:");
gets(str2);
x=compstr(str1,str2);
if(x==0)
printf("The two string are equal:");
else
printf("The two string are not equal:");
getch();
}
int compstr(char str1[],char str2[])
{
int y,i=0;
while(str1[i]!='\0'||str2[i]!='\0')
{
if(str1[i]!=str2[i])
{
y=-1;
break;
}
else
y=0;
i++;
}
return y;
}
0 comments:
Post a Comment