Write a program to compare two strings without using the
strcmp() function
Answer Posted / nomi mayana
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
char a[25],b[25];
int cnt=1,i=1;
cout<<"\n ENTER THE STRING 1 : ";
cin>>a;
cout<<"\n ENTER THE STRING 2 : ";
cin>>b;
while(a[i]!='\0' && b[i]!='\0')
{
if(a[i]==b[i])
{
cnt++;
}
else
{
cout<<"\n\n THE TWO STRINGS ARE NOT EQUAL";
}
i++;
}
if(i==cnt)
{
int n;
cout<<"\n\t\t~~~~~~~~~~COMPARISON RESULT~~~~~~~~~~~";
cout<<"\n THE GIVEN TWO STRINGS ARE SAME ";
}
//getch();
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is a method in c?
What is the benefit of using an enum rather than a #define constant?
what is uses of .net
What is a lookup table in c?
What oops means?
Explain how are portions of a program disabled in demo versions?
What are the different types of data structures in c?
How can I split up a string into whitespace-separated fields?
How can you increase the size of a statically allocated array?
the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b
How do you view the path?
Why is c not oop?
please send me the code for multiplying sparse matrix using c
Why do we use null pointer?
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?