Write a program to compare two strings without using the
strcmp() function
Answer Posted / ria varughese
#include <stdio.h>
#include <string.h>
void stringcmp(char s1[], char s2[]);
int main()
{
char str1[10],str2[10];
printf("\nEnter first String:");
scanf("%s",str1);
printf("\nEnter second String:");
scanf("%s",str2);
stringcmp(str1,str2);
return 0;
}
void stringcmp(char *s1, char *s2)
{
int i,j;
for(i=0;s1[i]!='\0';i++)
{
for(j=0;s2[j]!='\0';j++)
{
if(s1[i] == s2[j])
continue;
}
}
if (i==j)
{
printf("String s1:%s and s2:%s are EQUAL\n",s1,s2);
}
else
printf("String s1:%s and s2:%s are NOT EQUAL\n",s1,s2);
}
| Is This Answer Correct ? | 84 Yes | 89 No |
Post New Answer View All Answers
What are the advantages and disadvantages of c language?
How to create struct variables?
Explain how does free() know explain how much memory to release?
What are the similarities between c and c++?
What is the translation phases used in c language?
How can variables be characterized?
What is external variable in c?
int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer
What is 1f in c?
What is data type long in c?
What is the -> in c?
What does 3 periods mean in texting?
What do the functions atoi(), itoa() and gcvt() do?
Implement bit Array in C.
Define Spanning-Tree Protocol (STP)