Write a program in C to compare two strings without using string library functions.
#include <stdio.h>
void main()
{
char str1[100],str2[100];
int i;
printf(“Enter the first string:\n”);
fgets(str1, sizeof str1, stdin);
printf(“Enter the second string:\n”);
fgets(str2, sizeof str2, stdin);
for(i=0;str1[i]!=’\0′ || str2[i]!=’\0′;i++)
{
if(str1[i]!=str2[i])
{
printf(“Given strings are not identical\n”);
return;
}
}
printf(“Given strings are identical\n”);
}
Output:
Enter the first string:
Ekviz.com
Enter the second string:
Ekviz.com
Given strings are identical