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
Why c is called free form language?
I heard that you have to include stdio.h before calling printf. Why?
Are negative numbers true in c?
How pointers are declared?
to find the closest pair
Explain what are its uses in c programming?
Why functions are used in c?
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
What math functions are available for integers? For floating point?
Which node is more powerful and can handle local information processing or graphics processing?
What is a const pointer in c?
Why is extern used in c?
How is a macro different from a function?
Explain what are bus errors, memory faults, and core dumps?
What is the use of clrscr?