Write a program to compare two strings without using the
strcmp() function
Answer Posted / bhagwati lal paliwal(b.l.paliw
ALL PERSON ARE STUPIDS THEY DONT KNOW HERE WAT THE FUNCTION
STRCMP DO IT COMPARE BOTH STRING AND RETURN AN INTEGER
VALUE BUT ALL STUPID ARE COMPARING THE LENGTH OF STRING NOT
CHARACTER
Now the right answer by me follow me............
and tell me if this code work properly on
bl_paliwal77@yahoo.com
#include<stdio.h>
#include<string.h>
int cmpstr(char s1[10], char s2[10]);
int main() {
char arr1[10] = "Nodalo";
char arr2[10] = "nodalo";
printf(" %d", cmpstr(arr1, arr2));
return 0;
}
int cmpstr(char s1[10], char s2[10])
{
int i = strlen(s1);
int k = strlen(s2);
int bigger;
if (i < k) {
bigger = k;
}
else if (i > k) {
bigger = i;
}
else {
bigger = i;
}
for (i = 0; i < bigger; i++) {
if (s1[i] == s2[i])
{
//do nothing if value of both string are equal
}
else {
return (s1[i] - s2[i]);
}
}
return (0);
}
| Is This Answer Correct ? | 9 Yes | 5 No |
Post New Answer View All Answers
What are the characteristics of arrays in c?
What are structural members?
What is main () in c?
we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?
what do u mean by Direct access files? then can u explain about Direct Access Files?
What is the use of structure padding in c?
What is a spanning Tree?
What does volatile do?
Differentiate fundamental data types and derived data types in C.
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
There seem to be a few missing operators ..
Do pointers need to be initialized?
What is a volatile keyword in c?
What is dynamic dispatch in c++?
What are predefined functions in c?