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


Please Help Members By Posting Answers For Below Questions

One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.

2168


difference between native and cross compilers

1684


What type is sizeof?

595


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

1991


What is dynamic variable in c?

575






What is integer constants?

630


What is the difference between #include

and #include “header file”?

559


Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?

589


What is the hardest programming language?

685


Tell us something about keyword 'auto'.

674


What is assignment operator?

635


How do you initialize pointer variables?

620


how to execute a program using if else condition and the output should enter number and the number is odd only...

1669


What is the right way to use errno?

631


Is return a keyword in c?

612