Write a program to compare two strings without using the
strcmp() function
Answer Posted / vijay.benzamin
#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 ? | 54 Yes | 31 No |
Post New Answer View All Answers
What is the general form of a C program?
Explain the difference between getch() and getche() in c?
What is c preprocessor mean?
Is array name a pointer?
Can one function call another?
What is the data segment that is followed by c?
What do you mean by scope of a variable in c?
What is typedef struct in c?
Is that possible to add pointers to each other?
What is spark map function?
Why does everyone say not to use gets?
Is void a keyword in c?
How does selection sort work in c?
Why we use break in c?
Are comments included during the compilation stage and placed in the EXE file as well?