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

Answer Posted / raghu ram. n

#include<stdio.h>
void main()
{ char string1[50], string2[50];
int i=0;
printf("Enter First String :");
gets(string1);
printf("Enter Second String :");
gets(string2);
while(string1[i]!=0&&string2[i]!=0&&srting1[i]==string2[i])
i++;
if(string1[i]=='\0'&&string2[i]=='\0')
printf("Two strings are equal");
else
printf("Two string are not equal");
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the differences between Structures and Arrays?

618


What is table lookup in c?

641


What is the use of #define preprocessor in c?

625


How to find a missed value, if you want to store 100 values in a 99 sized array?

825


Explain what are the different data types in c?

767






Write a program to use switch statement.

671


program for reversing a selected line word by word when multiple lines are given without using strrev

1953


Can you please explain the scope of static variables?

614


Can a function argument have default value?

684


What is New modifiers?

684


What is the purpose of clrscr () printf () and getch ()?

607


What is the difference between malloc calloc and realloc in c?

657


How do you list a file’s date and time?

644


What is 1f in c?

1855


What is memory leak in c?

641