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
How can I read in an object file and jump to locations in it?
Is there a way to compare two structure variables?
How do you determine whether to use a stream function or a low-level function?
c language interview questions & answer
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
Write a code to generate a series where the next element is the sum of last k terms.
What does return 1 means in c?
What is %d called in c?
What is the difference between struct and union in C?
What is meant by 'bit masking'?
Write a program to know whether the input number is an armstrong number.
in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What does int main () mean?
Why void main is used in c?