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
What is sizeof array in c?
How we can insert comments in a c program?
Explain what are the different data types in c?
Explain why c is faster than c++?
How can I use a preprocessorif expression to ?
What is a keyword?
#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); }
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.
How does pointer work in c?
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?
write a program to concatenation the string using switch case?
Is c is a high level language?
What is c language & why it is used?
How can I swap two values without using a temporary?
What is the difference between new and malloc functions?