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

Answer Posted / sreevalli kamineni

main()
{
char a[50],b[50];
int i=0,flag;
puts("enter 1st string");
gets(a);
puts("enter 2nd string");
gets(b);
if(strlen(a)!=strlen(b))
puts("not identical");
else
{
while(a[i]!='\0')
{
if(a[i]==b[i])
{
i++;
flag=1;
}
else
{
puts("not identical");
}
}
if(flag==1) puts("identical");
}

Is This Answer Correct ?    13 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the header files used in c language?

571


List some basic data types in c?

549


What are the types of data structures in c?

592


Explain what is gets() function?

616


What does sizeof int return?

578






how can I convert a string to a number?

587


explain what are actual arguments?

624


What is the best way to comment out a section of code that contains comments?

767


which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +

1164


What is printf () in c?

572


What is the size of a union variable?

588


When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

573


What are identifiers in c?

621


What is formal argument?

636


Explain how are 16- and 32-bit numbers stored?

771