Write a program to compare two strings without using the
strcmp() function
Answer Posted / waqar nawaz
#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 ? | 104 Yes | 51 No |
Post New Answer View All Answers
What Is The Difference Between Null And Void Pointer?
What is the use of putchar function?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
What do header files do?
Why are algorithms important in c program?
Can a local variable be volatile in c?
Explain what are the __date__ and __time__ preprocessor commands?
Is it better to use malloc() or calloc()?
can we implement multi-threads in c.
Explain how do you convert strings to numbers in c?
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
What is merge sort in c?
When can a far pointer be used?
What is the difference between strcpy() and memcpy() function in c programming?
Write a program to swap two numbers without using a temporary variable?