Write a program to compare two strings without using the
strcmp() function
Answer Posted / shashi
#include<stdio.h>
#include<conio.h>
int stringcmp(char s1[], char s2[]);
int main()
{
char str1[10],str2[10];
printf("\nEnter first String:");
scanf("%s",str1);
printf("\nEnter second String:");
scanf("%s",str2);
if (stringcmp(str1,str2))
{
printf("String s1:%s and s2:%s are EQUAL\n",str1,str2);
}
else
printf("String s1:%s and s2:%s are NOT EQUAL\n",str1,str2);
getch();
return 0;
}
int stringcmp(char *s1, char *s2)
{
int flag=0;
char *count;
count=s1;
while(*count++)
{
flag=0;
if(*s1++==*s2++)
{
flag=1;
}
}
return flag;
}
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
How do you list a file’s date and time?
In which layer of the network datastructure format change is done
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
Write a c program to build a heap method using Pointer to function and pointer to structure ?
What are the basic data types associated with c?
What is the right way to use errno?
What is c mainly used for?
Can one function call another?
Why is structure important for a child?
What is f'n in math?
shorting algorithmS
What is the value of c?
What is the explanation for prototype function in c?
What is the size of structure pointer in c?
In c programming language, how many parameters can be passed to a function ?