Write a program to compare two strings without using the
strcmp() function
Answer Posted / raghu
#include<stdio.h>
#include<conio.h>
void main()
{
char a[100],b[100];
int i,c;
clrscr();
printf("enter first string");
scanf("%s",&a);
printf("enter second string");
scanf("%s",&b);
for(i=0;a[i]!='\0'&&b[i]!='\0';i++)
{
if(a[i]!=b[i])
{
c=1;
}
}
if(c==1)
{
printf("the strings do not match!");
}
else
{
printf("the strings match!");
}
getch();
}
| Is This Answer Correct ? | 8 Yes | 4 No |
Post New Answer View All Answers
What is difference between stdio h and conio h?
What are the advantages of using linked list for tree construction?
what do the 'c' and 'v' in argc and argv stand for?
What does the file stdio.h contain?
What is the hardest programming language?
What are the uses of a pointer?
What is the difference between c &c++?
What is the use of in c?
Why c is called a middle level language?
What is getch c?
What is the difference between functions abs() and fabs()?
What does 3 mean in texting?
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
can we implement multi-threads in c.
Are there namespaces in c?