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
What are the types of arrays in c?
Differentiate between Macro and ordinary definition.
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
What is pointer to pointer in c with example?
What is the c value paradox and how is it explained?
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
Do array subscripts always start with zero?
What is modifier & how many types of modifiers available in c?
How can I remove the leading spaces from a string?
How can you increase the size of a statically allocated array?
find out largest elemant of diagonalmatrix
What is the sizeof () a pointer?
What functions are used for dynamic memory allocation in c language?
What is the g value paradox?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?