Write a program to compare two strings without using the
strcmp() function
Answer Posted / dinesh
#include<stdio.h>
#include<conio.h>
void main()
{
char name1[20],name[20];
int i,j,c=0;
clrscr();
printf("enter two strings");
scanf("%s%s",name1,name);
for(i=0,j=0;name1[i]!='\0'||name[j]!='\0';i++,j++)
{
if(name1[i]!=name[j])
{
c++;
}
}
if(c==0)
printf("equal strings");
else
printf("not equal strings");
}
| Is This Answer Correct ? | 10 Yes | 6 No |
Post New Answer View All Answers
What is the difference between variable declaration and variable definition in c?
What are the disadvantages of a shell structure?
Why are all header files not declared in every c program?
What are the types of type qualifiers in c?
Explain what are reserved words?
Tell me the use of bit field in c language?
What is build process in c?
What is union and structure in c?
What is memcpy() function?
What is wild pointer in c?
Is c procedural or functional?
How are structure passing and returning implemented?
ATM machine and railway reservation class/object diagram
How can I manipulate strings of multibyte characters?
What are external variables in c?