Write a program to compare two strings without using the
strcmp() function

Answer Posted / belsia

void main()
{
char a[10],b[10];
int i=0;
scanf("%s%s",a,b);
if(strlen(a)!=strlen(b))
printf("they are different strings");
else
{
while(a[i]!='\0')
{
if(a[i]==b[i])
i++;
else
{
printf("They are different strings");
exit(0);
}
printf("Both are same");
}
getch();
}

Is This Answer Correct ?    27 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you find the day of the week given the date?

604


What is conio h in c?

609


can any one provide me the notes of data structure for ignou cs-62 paper

1692


Explain is it better to bitshift a value than to multiply by 2?

701


What is malloc and calloc?

558






Can the size of an array be declared at runtime?

593


What is the use of in c?

564


How many types of operators are there in c?

607


Where is volatile variable stored?

637


What is a list in c?

608


What is string constants?

651


How can you find out how much memory is available?

604


Is null valid for pointers to functions?

594


What is #define?

566


What is the use of a semicolon (;) at the end of every program statement?

752