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 is file in c language?

574


what are # pragma staments?

1624


how we can make 3d venturing graphics on outer interface

3998


Difference between macros and inline functions? Can a function be forced as inline?

706


Why is structure important for a child?

601






What does double pointer mean in c?

576


What is s or c?

591


Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)

685


What is scope and lifetime of a variable in c?

570


What is pointer in c?

736


How can I run c program?

677


What is the difference between typedef and #define?

539


what is a constant pointer in C

674


Is this program statement valid? INT = 10.50;

686


What are the advantages of Macro over function?

1190