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

Why clrscr is used in c?

587


What is the heap?

685


What is #define in c?

622


Are local variables initialized to zero by default in c?

551


What is c definition?

746






What does p mean in physics?

585


void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply

2226


What is the difference between union and anonymous union?

835


How can a process change an environment variable in its caller?

656


Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.

3691


Why c is called a middle level language?

634


Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

1764


What is the scope of static variables in c language?

630


What is the description for syntax errors?

615


What is the most efficient way to count the number of bits which are set in an integer?

593