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
Explain what is the use of a semicolon (;) at the end of every program statement?
Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
What are the different categories of functions in c?
What functions are used for dynamic memory allocation in c language?
What does 2n 4c mean?
What is the use of clrscr?
What tq means in chat?
How will you delete a node in DLL?
in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above
What's the right way to use errno?
Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol
What does c in a circle mean?
how to count no of words,characters,lines in a paragraph.
What are all different types of pointers in c?
What are reserved words?