Write a program to compare two strings without using the
strcmp() function
Answer Posted / vijay.benzamin
#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 ? | 54 Yes | 31 No |
Post New Answer View All Answers
What is getch c?
Why can’t we compare structures?
What is c language and why we use it?
how to write optimum code to divide a 50 digit number with a 25 digit number??
What is structure padding in c?
What is a nested formula?
What is a pointer value and address in c?
What is extern c used for?
Explain what is the stack?
write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.
Explain how can you tell whether two strings are the same?
What is an auto keyword in c?
Differentiate between full, complete & perfect binary trees.
How do I create a directory? How do I remove a directory (and its contents)?
what is the c source code for the below output? 10 10 10 10 10 10 10 10 10 10 9 9 7 6 6 6 6 6 6 9 7 5 9 7 3 2 2 5 9 7 3 1 5 9 7 3 5 9 7 4 4 4 4 5 9 7 8 8 8 8 8 8 8 8 9