Write a program to compare two strings without using the
strcmp() function
Answer Posted / bharat prajapati
#include <stdio.h>
#include <string.h>
main()
{
char s1[10],s2[10];
int i,j;
clrscr();
printf("\nEnter first String:");
scanf("%s",s1);
printf("\nEnter second String:");
scanf("%s",s2);
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);
getch();
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Are the variables argc and argv are always local to main?
How do we declare variables in c?
Explain can static variables be declared in a header file?
Is c high or low level?
Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays
Why is void main used?
Differentiate between Macro and ordinary definition.
What is the difference between fread buffer() and fwrite buffer()?
Explain Function Pointer?
What is use of bit field?
Is a house a shell structure?
Whats s or c mean?
What are the advantages of external class?
Can you explain the four storage classes in C?
Explain the difference between ++u and u++?