Write a program to compare two strings without using the
strcmp() function
Answer Posted / abhishek
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<conio.h>
void main()
{
clrscr();
char a[100],b[100];
int i,m;
cout<<"enter first string";
gets(a);
cout<<"enter second string";
gets(b);
for(i=0;a[i]!='\0'&&b[i]!='\0';i++)
{
if(a[i]!=b[i])
{
c=1;
}
}
if(c==1)
{cout<<"the strings do not match!";
}
else
{
cout<<"the strings match!";
}
getch();
}
| Is This Answer Correct ? | 7 Yes | 9 No |
Post New Answer View All Answers
Simplify the program segment if X = B then C ← true else C ← false
Why can't I perform arithmetic on a void* pointer?
What are dangling pointers in c?
Why do we use null pointer?
what are the different storage classes in c?
What is hash table in c?
What is meant by 'bit masking'?
What is the size of structure in c?
Dont ansi function prototypes render lint obsolete?
What are categories used for in c?
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks
What is advantage of pointer in c?
What is a #include preprocessor?
What is scope rule of function in c?
How does free() know explain how much memory to release?