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

Answer Posted / premkumar

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()

{
clrscr();
int c=0;
char a[10];

char b[10];
gets(a);
gets(b);
for(int i=0,j=0;b[i]!='\0'||a[j]!='\0';i++,j++)
{
if(a[i]!=b[j])
{
c++;

}

}
if(c==0)
cout<<"string match";
else
cout<<"string does not match";

getch();
}

Is This Answer Correct ?    69 Yes 24 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is sizeof array in c?

595


How we can insert comments in a c program?

634


Explain what are the different data types in c?

761


Explain why c is faster than c++?

575


How can I use a preprocessorif expression to ?

601






What is a keyword?

747


#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }

783


Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.

1597


How does pointer work in c?

621


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

603


write a program to concatenation the string using switch case?

1560


Is c is a high level language?

621


What is c language & why it is used?

582


How can I swap two values without using a temporary?

618


What is the difference between new and malloc functions?

580